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 columnMUNIID: Municipality ID columnCOUNTYID: 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:
- Road Connectivity: Verifying that precincts are connected by actual road networks
- Hierarchical Fallback: For rural areas with only local roads, fall back to municipality/county boundaries
- 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)
- Configure sampling: Use
01_configure_sampling.ipynbto set up parameters and test with a small sample - Run full ensemble: Use
02_run_ensemble.ipynbto 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 educationAIANNHID: 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file utgc-0.1.2.tar.gz.
File metadata
- Download URL: utgc-0.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e16edda724f5a9d772e5ec0a2c2d994d7993b87b87c69552ef60ec165035298
|
|
| MD5 |
16b0c520a1fbff62c59340fd3925f388
|
|
| BLAKE2b-256 |
1438473024f67d543b5ca2f7a2f71f9a385f3a2c2759ba93b20e5bab1fdeb032
|
File details
Details for the file utgc-0.1.2-py3-none-any.whl.
File metadata
- Download URL: utgc-0.1.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
341b37bb429d171776514b20913703eaca6f786e0e654a580084576d5017e65d
|
|
| MD5 |
1cbd9f100202bab8af7f640246f85f50
|
|
| BLAKE2b-256 |
25b3cf09fc393606c765022a113ece1b98362ba698666b0abde49795c16e3a78
|