To deter gerrymandering, many state constitutions require legislative districts to be "compact.'' Yet, the law offers few precise definitions other than "you know it when you see it,'' which effectively implies a common understanding of the concept.

Take a look at the figure below. It's pretty self-evident that Column 1's districts are more compact than Column 2. But what about Columns 3 and 4? The districts in column 4 look a lot more compact than those in column 3 - but three existing compactness algorithms would say otherwise - not just the three listed here, but all of the nearly 100 existing measures.The common-sense evaluation of a trained or lay observer has been challenging to replicate systematically. We hope to correct that, with a statistical method that predicts whether or not a district will look "compact" to a trained or lay observer. Our measure correctly evaluates all the districts in Column 4, and captures the seemingly-ineffable notion of compactness where existing measures fail.

Different districts with different types of compactness

We extended this exercise by surveying judges, academics, MTurkers, and other experts and non-experts to identify compact districts. We compared our measure's outputs to their subjective judgments, and found consistently high correlations - demonstrating that we have succesfully taught our algorithm to know compactness when it sees it.

Figure 6 from compactness paper
 
  • Our measure is described and supported with evidence in this paper:
    Aaron Kaufman, Gary King, and Mayya Komisarchik. Forthcoming. “How to Measure Legislative District Compactness If You Only Know it When You See It.” American Journal of Political Science. Copy at https://j.mp/2Fs3ESc
  • For any bugs or error reports, please make a report in the Github repo by filling out this form.
  • Discuss the package on Github Discussions here.
  • Code for the measure is available as an R package, here. Install it by typing devtools::install_github("aaronrkaufman/compactness")
  • Replication materials for our paper are found on the Harvard Dataverse.
  • We have an open-source API. If you are interested in implementing our tool on the fly, you can use the following curl command to pass a shapefile to our API:
    curl -X POST --form shp=@[name_of_shapefile.shp] --form shx=@[name_of_shapefile.shx] --form dbf=@[name_of_shapefile.dbf] --form prj=@[name_of_shapefile.prj] --form namecol=["identifier_column_name_in_quotes"] https://compactness.herokuapp.com/api/compact 
  • The measure is included in Dave's Redistricting App.
  • If you produce a redistricting application and would like to include our model, we would love to discuss how to help you with that!