Population Density¶
- night_light.socioeconomic.population.get_population(year: int = 2021, state: StateFIPS = StateFIPS.MASSACHUSETTS, **kwargs)¶
Fetch population data for a given year and state using the ACS 5-year survey.
This function retrieves population data for a specific state and year from the American Community Survey (ACS) 5-year dataset. It allows for additional filtering by specific population segments, including seniors, youths, and disabled individuals, if specified in the keyword arguments.
- Parameters:
year (int, optional) – The year for which to fetch the data. Defaults to 2021.
state (StateFIPS, optional) – The state for which to fetch the data, using FIPS code Enum. Defaults to StateFIPS.MASSACHUSETTS.
- Keyword Arguments:
seniors (bool, optional) – If True, fetches the senior population (ages 65+).
youths (bool, optional) – If True, fetches the youth population (ages 0-17).
disabled (bool, optional) – If True, fetches the disabled population.
- Returns:
A DataFrame containing the population data by census tract, with columns for:
”GEOID”
”total_population”
”senior_population” (if seniors=True)
”youth_population” (if youths=True)
”disabled_population” (if disabled=True)
- Return type:
pd.DataFrame
- night_light.socioeconomic.population_density.get_population_density(year: int = 2021, state: StateFIPS = StateFIPS.MASSACHUSETTS, **kwargs)¶
Calculate population density using ACS 5-year survey data.
This function retrieves population data and geographic shapes for census tracts within the specified state, calculates the area of each tract, and computes population density. Additional segments of the population (seniors, youths, and disabled individuals) can be included if specified, providing corresponding density values.
- Parameters:
year (int, optional) – The year for which to fetch the population data. Defaults to 2021.
state (StateFIPS, optional) – The state for which to calculate population density, specified using FIPS code Enum. Defaults to StateFIPS.MASSACHUSETTS.
- Keyword Arguments:
seniors (bool, optional) – If True, includes senior population density (ages 65+).
youths (bool, optional) – If True, includes youth population density (ages 0-17).
disabled (bool, optional) – If True, includes disabled population density.
- Returns:
A GeoDataFrame containing population density data by census tract, with columns for:
”GEOID”
”area_km2”
”total_population_density”
”senior_population_density” (if seniors=True)
”youth_population_density” (if youths=True)
”disabled_population_density” (if disabled=True)
- Return type:
gpd.GeoDataFrame