Skip to content

pycensus.census.countries.usa.elections_precinct.nyt2024

Nationwide 2024 presidential results at PRECINCT level (The New York Times precinct map data).

Source: github.com/nytimes/presidential-precinct-map-2024 -- one GeoJSON per state with the precinct polygon and votes_dem (Harris), votes_rep (Trump), votes_total and a 5-digit county FIPS prefix in GEOID. Official precinct boundaries are used where the states/counties publish them, estimated ones otherwise (official_boundary False). Alaska and a few counties are missing (countywide absentee tabulations); callers fall back to the county result there.

allocate_to_polygons moves the precinct votes onto any finer or coarser polygon set (blocks, block groups, tracts, H3 cells) dasymetrically: each precinct's votes are shared among the target polygons it overlaps in proportion to the target's population inside the overlap (population spread evenly over each target polygon).

load_state_precincts(state_fips, cache_dir=None)

Precinct polygons (EPSG:4326) of one state with county_fips, votes_dem, votes_rep, votes_total; None if unavailable.

Parameters:

Name Type Description Default
state_fips str

2-digit state FIPS.

required
cache_dir Optional[str]

Cache folder; None = the pycensus cache.

None

allocate_to_polygons(targets, precincts, pop_col='population')

Votes (dem / rep / total) per target polygon, index-aligned with targets.

Precincts with no population inside any target (or targets no precinct reaches) contribute nothing / get NaN, so the caller can fall back to the county result for them.

Parameters:

Name Type Description Default
targets GeoDataFrame

Target polygons with population.

required
precincts GeoDataFrame

Precincts with votes.

required
pop_col str

Population column of the targets.

'population'