pytidycensus.get_geography

pytidycensus.get_geography(geography, year=2022, state=None, county=None, keep_geo_vars=False, cache_dir=None, **kwargs)[source]

Download and load geographic boundary data from TIGER/Line shapefiles.

Parameters:
  • geography (str) – Geography type (e.g., ‘county’, ‘tract’, ‘block group’)

  • year (int, default 2022) – Census year for boundaries

  • state (str, int, or list, optional) – State(s) to filter data for

  • county (str, int, or list, optional) – County(ies) to filter data for (requires state)

  • keep_geo_vars (bool, default False) – Whether to keep all geographic variables

  • cache_dir (str, optional) – Directory for caching downloaded files

  • **kwargs – Additional filtering parameters

Returns:

Geographic boundary data

Return type:

geopandas.GeoDataFrame

Examples

>>> # Get county boundaries for Texas
>>> tx_counties = get_geography("county", state="TX", year=2022)
>>>
>>> # Get tract boundaries for Harris County, TX
>>> harris_tracts = get_geography(
...     "tract",
...     state="TX",
...     county="201",
...     year=2022
... )