Calculate Schwartzberg Compactness

comp_schwartz(
  plans,
  shp,
  use_Rcpp,
  perim_path,
  perim_df,
  epsg = 3857,
  ncores = 1
)

Arguments

plans

A redist_plans object or plans_matrix where each row indicates a district assignment and each column is a plan.

shp

A redist_map object, tibble, or data frame with an sf geometry column.

use_Rcpp

Logical. Use Rcpp?

perim_path

path to perimeter tibble saved by prep_perims()

perim_df

tibble of perimeters from prep_perims()

epsg

Numeric EPSG code to use to project the shapefile, if needed. Default is 3857.

ncores

Integer number of cores to use. Default is 1.

Value

A numeric vector. Can be shaped into a district-by-plan matrix.

References

Schwartzberg, Joseph E. 1966. Reapportionment, Gerrymanders, and the Notion of Compactness. Minnesota Law Review. 1701.

Examples

data(nh)
data(nh_m)
# For a single plan:
comp_schwartz(plans = nh$r_2020, shp = nh)
#> [1] 0.4821177 0.3978395

# Or many plans:
comp_schwartz(plans = nh_m[, 3:5], shp = nh)
#> [1] 0.4851649 0.5911701 0.6573506 0.5168515 0.5929185 0.4198649