pytidycensus.geography
Geographic boundary data retrieval and processing using TIGER shapefiles.
Functions
|
Get block group boundaries for a state, optionally filtered by county. |
|
Get US county boundaries, optionally filtered by state. |
|
Download and load geographic boundary data from TIGER/Line shapefiles. |
|
Get US state boundaries. |
|
Get census tract boundaries for a state, optionally filtered by county. |
Classes
|
Downloads and processes TIGER/Line shapefiles from the US Census Bureau. |
- class pytidycensus.geography.TigerDownloader(cache_dir=None)[source]
Bases:
object
Downloads and processes TIGER/Line shapefiles from the US Census Bureau.
- BASE_URL = 'https://www2.census.gov/geo/tiger'
- __init__(cache_dir=None)[source]
Initialize TIGER downloader.
- Parameters:
cache_dir (str, optional) – Directory for caching downloaded files
- pytidycensus.geography.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:
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 ... )
- pytidycensus.geography.get_state_boundaries(year=2022, **kwargs)[source]
Get US state boundaries.
- Return type:
- pytidycensus.geography.get_county_boundaries(state=None, year=2022, **kwargs)[source]
Get US county boundaries, optionally filtered by state.
- Return type:
- pytidycensus.geography.get_tract_boundaries(state, county=None, year=2022, **kwargs)[source]
Get census tract boundaries for a state, optionally filtered by county.
- Return type: