Commit 3b1180f
Add census block-level geographic assignment with comprehensive lookups (#484)
* Add census block-level geographic assignment with comprehensive lookups
- Assign census blocks using P(block|CD) from Census population data
- Look up all geography from block GEOID for consistency:
- County, tract, state (from GEOID structure)
- CBSA/metro area (via NBER county crosswalk)
- SLDU/SLDL (state legislative districts)
- Place/City FIPS (via Census BAF)
- PUMA (via tract crosswalk)
- VTD (voting tabulation district)
- Add block_crosswalk.csv.gz (8.1M blocks) with BAF data
- Add make_block_crosswalk.py to generate crosswalk from Census BAFs
- Add comprehensive tests for all geography lookups
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add changelog entry
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Fix black formatting
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Trigger CI
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Fix black formatting (26.1.0)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Save all geography variables to CD-stacked datasets
Updates stacked_dataset_builder.py to:
- Set all geography variables from block assignment (block_geoid, tract_geoid,
cbsa_code, sldu, sldl, place_fips, vtd, puma)
- Include these variables in the saved h5 files
These variables enable granular geographic analysis at multiple levels:
state legislative districts, census tracts, metro areas, cities, etc.
Requires policyengine-us#7249 for the variable definitions.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add ZCTA (ZIP code) lookup from census block
- Add ZCTA column to block_crosswalk.csv.gz from Census relationship file
- Add get_zcta_from_block() function and include zcta in assign_geography_for_cd()
- Save zcta to CD-stacked dataset output
- Add tests for ZCTA lookup
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Update policyengine-us to v1.524.1 for geography variables
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: baogorek@gmail.com <baogorek@gmail.com>1 parent ee06502 commit 3b1180f
9 files changed
Lines changed: 1411 additions & 12 deletions
File tree
- policyengine_us_data
- datasets/cps/local_area_calibration
- storage
- calibration_targets
- tests/test_local_area_calibration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments