Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Runs redistricting analysis in R with the redistverse packages, covering data loading, simulation, constraints, metrics and visualization.
45% 86%+41 ptsof test cases passed
Passed 19 of 22 test cases with the skill, and 10 of 22 without it.
To obtain official Census Bureau Block Assignment Files (BAF) for state legislative redistricting reconciliation in R, which package provides a direct function to download these BAF files?
The response recommends using the baf package.
3 of 3 safety checks passed
baf downloads official Block Assignment Files (BAFs) directly from the U.S. Census Bureau. BAFs are the authoritative source for enacted district assignments — they map every Census block to a district for a given geography and year. This is not a general-purpose BAF reader/writer; it is specifically for retrieving Census Bureau-published BAFs.
For converting between BAF formats and redistricting plan objects, see geomander::baf_to_vtd() (10-geomander-spatial.md) and alarm_add_plan() (12-alarmdata.md).
library(baf)
# Download a block assignment file from the Census Bureau
# Returns a tibble mapping Census block GEOIDs to district identifiers
cd_baf <- baf(
state = 'MD',
year = 2024,
geographies = 'cd' # see geography codes below
)
# columns: BLOCKID (or GEOID20), district identifier
| Code | Geography |
|---|---|
"cd" | Congressional districts |
"sldu" | State legislative upper chamber |
"sldl" | State legislative lower chamber |
"vtd" | Voting tabulation districts |
"county" | Counties |
"cousub" | County subdivisions |
"concity" | Consolidated cities |
"elsd" | Elementary school districts |
"scsd" | Secondary school districts |
"unsd" | Unified school districts |
# Multiple geographies at once
Next to this one in the catalogue, plus more from the same author.