Title: | Interactive Redistricting |
---|---|
Description: | A point and click editor for districts built on 'shiny' and 'Leaflet'. Users can draw districts and calculate standard redistricting metrics, like compactness or the number of administrative splits. Maps can be exported as assignment files or shapefiles, readable by most other redistricting software. |
Authors: | Christopher T. Kenny [aut, cre] , Cory McCartan [aut] , leaflet contributors [cph] (setShapeStyle code adapted from leaflet package.) |
Maintainer: | Christopher T. Kenny <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.0.0.9000 |
Built: | 2024-10-27 02:49:11 UTC |
Source: | https://github.com/christopherkenny/redistio |
This file contains demographic, partisan, and geographic data for DC at the voting district level.
sf
object
GEOID20
US Census Geographic Identifier
state
state abbreviation
county
county name
vtd
voting district identifier
pop
total population
pop_hisp
Hispanic population
pop_white
White, non-Hispanic population
pop_black
Black, non-Hispanic population
pop_aian
American Indian and Alaskan Native, non-Hispanic population
pop_asian
Asian, non-Hispanic population
pop_nhpi
Native Hawaiian and Pacific Islander, non-Hispanic population
pop_other
Other, non-Hispanic population
pop_two
Two or More Races, non-Hispanic population
vap
voting age population
vap_hisp
Hispanic voting age population
vap_white
White, non-Hispanic voting age population
vap_black
Black, non-Hispanic voting age population
vap_aian
American Indian and Alaskan Native, non-Hispanic voting age population
vap_asian
Asian, non-Hispanic voting age population
vap_nhpi
Native Hawaiian and Pacific Islander, non-Hispanic voting age population
vap_other
Other, non-Hispanic voting age population
vap_two
Two or More Races, non-Hispanic voting age population
pre_16_dem_cli
votes for Clinton 2016, President (D)
pre_16_rep_tru
votes for Trump 2016, President (R)
uss_18_dem_bro
votes for Brown 2018, Shadow Senate (D)
atg_18_dem_rac
votes for Karl Racine, Attorney General (D)
pre_20_dem_bid
votes for Biden 2020, President (D)
pre_20_rep_tru
votes for Trump 2020, President (R)
uss_20_dem_str
votes for Strauss 2020, Shadow Senate (D)
uss_20_rep_wei
votes for Weiss 2020, Shadow Senate (R)
arv_16
average Republican vote in 2016
adv_16
average Democratic vote in 2016
arv_18
average Republican vote in 2018
adv_18
average Democratic vote in 2016
arv_20
average Republican vote in 2020
adv_20
average Democratic vote in 2016
nrv
normal Republican vote
ndv
normal Democratic vote
geometry
sf geometry
adv_nbr
Advisory Neighborhood names estimated to VTDs
ward
2022 ward lines estimated to VTDs
data(dc)
data(dc)
Interactive Plan Drawing
draw( shp, init_plan, ndists, palette, layers = NULL, pop_tol = 0.05, pop_col = "pop", adj_col = "adj", split_cols = guess_admins, elect_cols = guess_elections, demog_cols = guesstimate_demographics, hover_fn = hover_precinct, opts = redistio_options() )
draw( shp, init_plan, ndists, palette, layers = NULL, pop_tol = 0.05, pop_col = "pop", adj_col = "adj", split_cols = guess_admins, elect_cols = guess_elections, demog_cols = guesstimate_demographics, hover_fn = hover_precinct, opts = redistio_options() )
shp |
an |
init_plan |
Plan to initialize with. |
ndists |
Number of districts to draw if |
palette |
Color palette to fill shapes with. Default is |
layers |
Named list of |
pop_tol |
the population tolerance. |
pop_col |
Name of column in |
adj_col |
Name of column in |
split_cols |
Names of column in |
elect_cols |
Names of column in |
demog_cols |
Names of column in |
hover_fn |
Function to generate tables for mouse hovering. Default is |
opts |
list of options. Default is |
Shiny app
if (interactive()) { draw(dc, dc$ward) draw(dc, dc$ward, layers = list(neighborhoods = 'adv_nbr')) }
if (interactive()) { draw(dc, dc$ward) draw(dc, dc$ward, layers = list(neighborhoods = 'adv_nbr')) }
Guess which columns contain administrative units
guess_admins(shp)
guess_admins(shp)
shp |
an |
a named list
of types
guess_admins(dc)
guess_admins(dc)
Guess which columns contain election data
guess_elections(shp)
guess_elections(shp)
shp |
an |
a named list
of columns
guess_elections(dc)
guess_elections(dc)
Guess and estimate which columns contain demographic data
guesstimate_demographics(shp)
guesstimate_demographics(shp)
shp |
an |
a named list
of columns
guesstimate_demographics(dc)
guesstimate_demographics(dc)
tibble
of precinct statsCreate a tibble
of precinct stats
hover_precinct(shp, ...)
hover_precinct(shp, ...)
shp |
a tibble::tibble with precinct stats |
... |
named tidyselections |
hover_precinct(dc, 1, pop = dplyr::starts_with('pop'), vap = dplyr::starts_with('vap'))
hover_precinct(dc, 1, pop = dplyr::starts_with('pop'), vap = dplyr::starts_with('vap'))
redistio
Set options for redistio
redistio_options( theme = "flatly", panels = c("elections", "demographics", "integrity", "algorithms"), select_color = "purple", palette_pop = "Purples", palette_pct = "PuOr", palette_party = ggredist::ggredist$partisan, map_tiles = "CartoDB.Positron", leaflet_height = "91vh", crs = 4326, na_color = "#0000", layer_weight = 1.5, layer_color = "#000000", locked_districts = NULL, use_algorithms = TRUE, alg_max_districts = 3, alg_max_sims = 100, use_planscore = TRUE, save_assignment_path = "redistio.csv", save_shape_path = "redistio.geojson", ... )
redistio_options( theme = "flatly", panels = c("elections", "demographics", "integrity", "algorithms"), select_color = "purple", palette_pop = "Purples", palette_pct = "PuOr", palette_party = ggredist::ggredist$partisan, map_tiles = "CartoDB.Positron", leaflet_height = "91vh", crs = 4326, na_color = "#0000", layer_weight = 1.5, layer_color = "#000000", locked_districts = NULL, use_algorithms = TRUE, alg_max_districts = 3, alg_max_sims = 100, use_planscore = TRUE, save_assignment_path = "redistio.csv", save_shape_path = "redistio.geojson", ... )
theme |
a name of a bootswatch preset theme or other |
panels |
which panels to display in the app, |
select_color |
a color to use for highlighting selected districts |
palette_pop |
a color palette to use for whole people |
palette_pct |
a color palette to use for percentages of people |
palette_party |
a color palette to use for parties |
map_tiles |
a tileset to use for the map background, from |
leaflet_height |
height to pass to |
crs |
a coordinate reference system to use in |
na_color |
a color to use for unassigned precincts |
layer_weight |
a stroke width to use for layers in |
layer_color |
colors to use for layers in |
locked_districts |
districts to lock on app start to stop edits |
use_algorithms |
whether to use redistricting simulation algorithms |
alg_max_districts |
maximum number of districts to use in algorithms |
alg_max_sims |
maximum number of simulations to use in algorithms |
use_planscore |
whether to use PlanScore to evaluate plans |
save_assignment_path |
Output path to save assignment file to. |
save_shape_path |
Output path to save shapefile to. |
... |
additional arguments (currently ignored) |
a list
redistio_options()
redistio_options()