Sign inSign up

jamessaxon/c4

By jamessaxon

•Updated over 7 years ago

c4 districting software with dependencies

Image
0

156

jamessaxon/c4 repository overview

This container packs the C4 redistricting software⁠ along with all of its dependencies. The container is about 2GB.

⁠Running C4 Docker

Running from scratch is as simple as:

docker run -v $(pwd)/res/:/C4/res/ -e STATE=pa -e SEED=2 -e METHOD=POWER --rm -it  jamessaxon/c4:replication

This means:

  • Run the c4 software as in this image (docker run [...] jamessaxon/c4:replication)
  • Mount the local directory called res/ to /C4/res/ in the container. Results written here will be available when the jobs completes. You must make the res/ directory!!
  • Environment variables / arguments: simulate districts for the STATE of Pennsylvania (USPS code pa), with SEED of 2 (any number, but < 1000 will format better), using the POWER diagram METHOD. You can also specify the SHADING (-e SHADING=all).
    • The possible methods are POWER DIST RADII IPQ CIRCLES HULL_P HULL_A INERTIA AXIS SPLIT PATH_FRAC. Several of these run several methods in sequence. For instance CIRCLES runs the exchange, reock and ehrenburg methods, and RADII includes rohrbach, harm_radius, mean_radius, and dyn_radius .
    • The SHADING options are: district (just colors), target (ratio to target population), density (show population centers), scores (show spatial scores), counties (overlay county geometries), and "all" or "none". The default is none.
  • Remove (--rm) the container when it exits.
  • Run interactively and allow input (-it).

Of course, you can also run interactively with /bin/bash and just cd to C4 to use run.py with all of its arguments. In that case, skip to Running C4⁠, below.

For large-scale jobs, I run C4 as a Docker container on AWS. The Dockerfile changes very slightly, with AWS keys and s3 tools (see DockerfileAWS⁠). The scripts for building the container⁠ and launching jobs⁠ are also in this directory (though they won't run, without dependencies or passwords!).

⁠Outputs

Four types of files will be written to res/ (your local directory). Note again that, running with docker, the directory must be mounted to a local file.

  1. JSON files containing a summary of the simulation will be written to res/json/[state usps]_[method]_s[seed]_c[cycle].json. These files contain a summary of the entire run: the tract to district assignment, the spatial parameters of the districts, the partisan voting (if available for that state), race and ethnicity, voter balance (PopulationDeviation), the method used, and so forth (run jq keys file.json to see this). These data
  2. CSV files containing simply the tract to district assignment. This is just a two-column assignment: row number (equivalent to county + tract geoid, though perhaps a poor technical choice) and the district. This will be written to res/[state usps]/[method]/s[seed]/c[cycle]/final.csv.
  3. GeoJSON files of the districting plans, final.geojson, in the same directory as (2). These contain the basic plan and some of the information of (1). They are in in the EPSG 4326 coordinate reference system, and display nicely on GitHub or Gist or in Leaflet etc.
  4. Finally, final_*.pdf are static maps of the districting plans. There will be one map for each shading method used.

Tag summary

Content type

Image

Digest

Size

729.2 MB

Last updated

over 7 years ago

docker pull jamessaxon/c4:replication