Skip to main content

GerryChain utilities for nonpartisan Utah redistricting ensembles

Project description

UT_GerryChain

This project uses GerryChain to generate neutral redistricting ensembles for Utah.

Data Files

The project works with any data/*.geojson file (UT_blocks.geojson, UT_vtds.geojson, UT_vtd_parts.geojson). All files must contain:

  • TOTPOP: Total population column
  • MUNIID: Municipality ID column
  • COUNTYID: County ID column
  • Additional COI (Communities of Interest) columns as needed

Configure neutral sampling in notebook

Use 01_configure_sampling.ipynb to:

  • Configure neutral parameters (no partisan metrics)
  • Configure transitability analysis (road connectivity and water barriers)
  • Run a short neutral sample for sanity checks
  • Export a YAML configuration to results/configurations/sampling_params.yaml

Transitability Analysis

UT_GerryChain now includes transitability analysis to ensure districts are connected by actual roads and not separated by impassable barriers. This implements Utah's requirement for "ease of travel throughout district" by:

  1. Road Connectivity: Verifying that precincts are connected by actual road networks
  2. Hierarchical Fallback: For rural areas with only local roads, fall back to municipality/county boundaries
  3. Water Barriers: Remove connections that cross major water bodies (Great Salt Lake, Lake Powell, etc.)

Data Requirements

You can now build the transitability graph offline from the original geography sources and load it at runtime.

Offline preprocessing (recommended)

Build once and reuse:

Transitability analysis uses edge penalties to discourage districts that aren't well-connected by roads. The transitability CSV file (e.g., data/transitability/precinct_no_roads.csv) can be generated by an external pipeline and should contain edge pairs (u, v) that should be penalized.

If the transitability CSV file is not found, the code will skip edge penalties with a warning.

Configuration

Transitability can be configured in the notebook or YAML:

transitability:
  enable: true
  remove_water_barriers: true
  verify_road_connectivity: true
  precomputed_path: data/transitability/transitability.graphml
  min_lake_size_sqkm: 1.0
  min_river_size_sqkm: 0.5
  road_buffer_meters: 500
  water_threshold: 0.5

Running Ensembles

Using Notebooks (Recommended)

  1. Configure sampling: Use 01_configure_sampling.ipynb to set up parameters and test with a small sample
  2. Run full ensemble: Use 02_run_ensemble.ipynb to load the configuration and run a full ensemble

Column Names

The geojson files use the following column names for Communities of Interest:

  • HIGHEREDID: Institutions of higher education
  • AIANNHID: American Indian/Alaska Native Areas (formerly RESERVATION_ID)
  • MILITID: Military installations (formerly MILITARY_ID)
  • CBSAID: Core Based Statistical Areas / Metro areas (formerly METRO_ID)
  • SCHDISTID: School districts

Note: WATER_ID and BASIN_ID are no longer used.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

utgc-0.1.1a0.tar.gz (58.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

utgc-0.1.1a0-py3-none-any.whl (51.3 kB view details)

Uploaded Python 3

File details

Details for the file utgc-0.1.1a0.tar.gz.

File metadata

  • Download URL: utgc-0.1.1a0.tar.gz
  • Upload date:
  • Size: 58.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for utgc-0.1.1a0.tar.gz
Algorithm Hash digest
SHA256 cee8ad8de0da8297fca42b682eb15e753e68d38fe5625db27f99daf343d648f5
MD5 9e2d8f6c1f12b18e9586da58c2f19226
BLAKE2b-256 e399dcc8d839658a21ab0611100f8041d7283b1340b779b6b0c90632169df699

See more details on using hashes here.

File details

Details for the file utgc-0.1.1a0-py3-none-any.whl.

File metadata

  • Download URL: utgc-0.1.1a0-py3-none-any.whl
  • Upload date:
  • Size: 51.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for utgc-0.1.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc27570d80bbb373f26347c1680280e79c5e4e49e102d2b0d36fd3e75c11c350
MD5 40510819e4f4ad6cb3a41c146058fcd2
BLAKE2b-256 144c0768b8868795418d5b991bed68402926b420a2127d75d24cff1ccd290572

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page