Learn R Programming

⚠️There's a newer version (2.5.2) of this package.Take me there.

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.3.0

License

MIT + file LICENCE

Issues

Pull Requests

Stars

Forks

Maintainer

Christopher T. Kenny

Last Published

February 15th, 2024

Functions in geomander (2.3.0)

baf_to_vtd

Estimate Plans from a Block Assignment File to Voting Districts
estimate_down

Estimate Down Levels
geo_estimate_up

Estimate Up Geography Levels
get_alarm

Get ALARM Dataset
estimate_up

Estimate Up Levels
create_block_table

Create Block Level Data
clean_vest

Clean VEST Names
geos_circle_center

Get the centroid of the maximum inscribed circle
count_connections

Count Times Precincts are Connected
geo_estimate_down

Estimate Down Geography Levels
compare_adjacencies

Compare Adjacency Lists
get_vest

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

Filter to Intersecting Pieces
geo_match

Match Across Geographic Layers
heda_doi

Vest DOIs
geo_plot_group

Create Plots of Shapes by Group with Connected Components Colored
geo_plot

Plots a Shape with Row Numbers as Text
get_heda

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

Get Dave's Redistricting App Dataset
local_morans

Compute Local Moran's I
heda_party

HEDA Parties
heda_states

List Available States from HEDA Dataverse
orange

orange
local_gearys

Compute Local Geary's C
st_centerish

Get the kind of center of each shape
split_precinct

Split a Precinct
create_tract_table

Create Tract Level Data
geo_sort

Sort Precincts
vest_states

List Available States from VEST Dataverse
vest_party

VEST Parties
get_rpvnearme

Get Racially Polarized Voting Dataset from RPV Near Me
get_lewis

Get historical United States Congressional District Shapefiles
global_gearys

Compute Global Geary's C
geo_trim

Trim Away Small Pieces
regionalize

Estimate Regions by Geographic Features
rockland

rockland
vest_abb

VEST Abbreviations
seam_sew

Suggest Edges to Connect Two Sides of a Border
seam_rip

Remove Edges along a Boundary
nrcsd

nrcsd
r2dra

R to DRA
precincts

precincts
dra2r

DRA to R
geomander-package

tools:::Rd_package_title("geomander")
st_circle_center

Get the centroid of the maximum inscribed circle
geos_centerish

Get the kind of center of each shape
global_morans

Compute Global Moran's I
subtract_edge

Subtract Edges from an Adjacency List
vest_doi

VEST DOIs
gstar_i

Compute Standardized Getis Ord G*i
suggest_component_connection

Suggest Connections for Disconnected Groups
suggest_neighbors

Suggest Neighbors for Lonely Precincts
va_vtd

va_vtd
va_blocks

va_blocks
seam_adj

Filter Adjacency to Edges Along Border
%>%

Pipe operator
towns

towns
va18sub

va18sub
seam_geom

Filter Shape to Geographies Along Border
alarm_states

List Available States from ALARM Data
checkerboard_adj

Checkerboard Adjacency
add_edge

Add Edges to an Adjacency List
checkerboard

Checkerboard
adjacency

Build Adjacency List
block2prec_by_county

Aggregate Block Table by Matches and County
block2prec

Aggregate Block Table by Matches
check_polygon_contiguity

Check Polygon Contiguity
check_contiguity

Check Contiguity by Group