Skip to content

pycensus.census.countries.usa.geography

Boundary fetching shared by every US census source (ACS, DHC, LODES, ...).

Technical aspects

Boundaries come from pygris <https://walker-data.com/pygris/>_, which wraps the Census Bureau's TIGER/Line shapefiles. Every pygris call here uses cache=False -- persistence is handled entirely by :mod:pycensus.cache, one level higher in the call stack (in each source's loader.py), not by pygris' own shapefile cache. This module only adds: a normalized GEOID column, optional water erasure (pygris.utils.erase_water), and standard-level fallback resolution (:func:pycensus.geometry_levels.resolve_level) -- the pieces every source needs identically.

Source

https://walker-data.com/pygris/

states_in_aoi(aoi, year)

Return the USPS abbreviations of every state intersecting aoi.

Parameters:

Name Type Description Default
aoi GeoDataFrame

Area of interest, any CRS.

required
year int

TIGER/Line vintage year for the state boundaries.

required

Returns:

Type Description
List[str]

List of two-letter state abbreviations.

load_boundaries(level, state, year, erase_water=None)

Fetch a single state's boundaries for one census geography level.

Parameters:

Name Type Description Default
level str

Standard geometry level name (:data:pycensus.geometry_levels.STANDARD_LEVELS), resolved through :data:pycensus.usa.constants.LEVEL_FALLBACK if the US has no native geography for it.

required
state Optional[str]

State name, abbreviation, or FIPS code (None with level="state": every state).

required
year int

TIGER/Line vintage year.

required
erase_water Optional[bool]

Whether to clip inland water bodies. Defaults to :data:pycensus.usa.constants.ERASE_WATER for the resolved level.

None

Returns:

Type Description
GeoDataFrame

GeoDataFrame with a GEOID column, geometry, in EPSG:4326.

Raises:

Type Description
KeyError

If level does not resolve to a known geography level.

load_boundaries_multi(level, states, year, erase_water=None, aoi=None)

Fetch and concatenate boundaries across one or more states, optionally clipped to an AOI.

Parameters:

Name Type Description Default
level str

Standard geometry level name.

required
states Union[str, List[str]]

State name(s)/abbreviation(s)/FIPS code(s).

required
year int

TIGER/Line vintage year.

required
erase_water Optional[bool]

Whether to clip inland water bodies.

None
aoi Optional[GeoDataFrame]

If given, the result is filtered to geometries intersecting it.

None

Returns:

Type Description
GeoDataFrame

GeoDataFrame with a GEOID column, geometry, in EPSG:4326.