Learn R Programming

geomander

Focuses on creating data sets and other tools that help make understanding gerrymandering faster and easier. Designed for easy preparation to run simulation analysis with the R package redist, but is aimed at the geographic aspects of redistricting, not partitioning methods. Most of these tools are gathered from seminar papers and do not correspond to a single publication.

Installation

You can install the released version of geomander from CRAN with:

install.packages("geomander")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("christopherkenny/geomander")

Examples

A very common task is aggregating block data to precincts.

library(geomander)
library(tidyverse)
#> ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
#> ✔ dplyr     1.1.4     ✔ readr     2.1.4
#> ✔ forcats   1.0.0     ✔ stringr   1.5.1
#> ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
#> ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
#> ✔ purrr     1.0.2     
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ dplyr::lag()    masks stats::lag()
#> ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
 
# load precincts
data('va18sub')

# create block data
block <- create_block_table(state = 'VA', county = '087')  

# match the geographies
matches <- geo_match(from = block, to = va18sub)

# Aggregate
prec <- block2prec(block_table = block, matches = matches)

Other important tasks include breaking data into pieces by blocks underlying them.

library(geomander)
library(tidyverse)
 
# load precincts
data("va18sub")

# subset to target area
va18sub <- va18sub |> filter(COUNTYFP == '087')

Then we can get common block data:

block <- create_block_table(state = 'VA', county = '087')  

And estimate down to blocks

disagg <- geo_estimate_down(from = va18sub, to = block, wts = block$vap, value = va18sub$G18USSRSTE)

For more information, see the documentation and vignettes, available at https://christophertkenny.com/geomander/

Copy Link

Version

Install

install.packages('geomander')

Monthly Downloads

574

Version

2.5.2

License

MIT + file LICENCE

Issues

Pull Requests

Stars

Forks

Maintainer

Christopher T. Kenny

Last Published

December 11th, 2025

Functions in geomander (2.5.2)

geo_sort

Sort Precincts
get_rpvnearme

Get Racially Polarized Voting Dataset from RPV Near Me
heda_states

List Available States from HEDA Dataverse
rockland

rockland
geo_filter

Filter to Intersecting Pieces
geos_centerish

Get the kind of center of each shape
vest_party

VEST Parties
seam_adj

Filter Adjacency to Edges Along Border
suggest_component_connection

Suggest Connections for Disconnected Groups
subtract_edge

Subtract Edges from an Adjacency List
seam_rip

Remove Edges along a Boundary
va_vtd

va_vtd
seam_geom

Filter Shape to Geographies Along Border
geo_match

Match Across Geographic Layers
r2dra

R to DRA
get_alarm

Get ALARM Dataset
regionalize

Estimate Regions by Geographic Features
vest_doi

VEST DOIs
heda_party

HEDA Parties
va18sub

va18sub
get_vest

Get Voting and Election Science Team ("VEST") Dataset
geos_circle_center

Get the centroid of the maximum inscribed circle
global_gearys

Compute Global Geary's C
suggest_neighbors

Suggest Neighbors for Lonely Precincts
local_gearys

Compute Local Geary's C
precincts

precincts
global_morans

Compute Global Moran's I
orange

orange
seam_sew

Suggest Edges to Connect Two Sides of a Border
vest_abb

VEST Abbreviations
heda_doi

Vest DOIs
gstar_i

Compute Standardized Getis Ord G*i
va_blocks

va_blocks
towns

towns
split_precinct

Split a Precinct
vest_states

List Available States from VEST Dataverse
get_dra

Get Dave's Redistricting App Dataset
get_heda

Get Harvard Election Data Archive ("HEDA") Dataset
local_morans

Compute Local Moran's I
st_circle_center

Get the centroid of the maximum inscribed circle
st_centerish

Get the kind of center of each shape
nrcsd

nrcsd
alarm_states

List Available States from ALARM Data
checkerboard

Checkerboard
check_contiguity

Check Contiguity by Group
block2prec

Aggregate Block Table by Matches
adjacency

Build Adjacency List
add_edge

Add Edges to an Adjacency List
block2prec_by_county

Aggregate Block Table by Matches and County
baf_to_vtd

Estimate Plans from a Block Assignment File to Voting Districts
checkerboard_adj

Checkerboard Adjacency
check_polygon_contiguity

Check Polygon Contiguity
estimate_down

Estimate Down Levels
clean_vest

Clean VEST Names
geo_plot_group

Create Plots of Shapes by Group with Connected Components Colored
compare_adjacencies

Compare Adjacency Lists
geo_plot

Plots a Shape with Row Numbers as Text
geo_estimate_up

Estimate Up Geography Levels
geo_estimate_down

Estimate Down Geography Levels
get_lewis

Get historical United States Congressional District Shapefiles
dra2r

DRA to R
create_tract_table

Create Tract Level Data
count_connections

Count Times Precincts are Connected
geomander-package

tools:::Rd_package_title("geomander")
create_block_table

Create Block Level Data
estimate_up

Estimate Up Levels
geo_trim

Trim Away Small Pieces