transitlos.population¶
Join an access-score GeoDataFrame with population data.
Composition decision (read before changing this file): access_gdf is
street-edge (line) geometry, while population sources are polygon (US
Census ACS/DHC tract/blockgroup) or raster (WorldPop) geometry. Rather than
rasterizing the edges to H3 first, this module treats the population
source as the target polygon level and aggregates access_gdf's
level_of_service (and any other requested edge columns) onto it via
geohierarchy.edges_to_level -- this is the same composition
UrbanAccessAnalyzer.api.AccessibilityAnalyzer.to_level/.to_h3 already use
internally, just with the population source's own polygons as level_gdf
instead of an H3 grid or admin boundary layer supplied by the caller. This
keeps population counts exactly as reported by the source (no raster
resampling error from forcing them onto an edge-derived grid) and produces
one row per population polygon with both a population and an aggregated
level_of_service column, ready for equity.equity_statistics.
For WorldPop (population_source="worldpop"), which ships a raster rather
than a polygon layer, the raster is first vectorized into a per-pixel
polygon grid (_worldpop_raster_to_gdf) so the same edges_to_level call
can be reused. This is O(n_pixels) in memory, so pass a coarse resolution
("1km" is the WorldPop default probed here) for large AOIs.
cross_with_population(access_gdf, population_source='worldpop', aoi=None, region_for_census=None, id_col='edge_id', access_columns=None, census_level='tract', census_dataset='acs', worldpop_date=None, worldpop_resolution='1km', worldpop_folder=None, **kwargs)
¶
Combine access_gdf (street edges with an level_of_service column) with population data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_gdf
|
GeoDataFrame
|
Street-edges GeoDataFrame with an |
required |
population_source
|
str
|
|
'worldpop'
|
aoi
|
Optional[GeoDataFrame]
|
Area of interest, required for |
None
|
region_for_census
|
Optional[Union[str, list]]
|
For |
None
|
id_col
|
str
|
Name to give the population polygon's unique-id column in
the returned GeoDataFrame ( |
'edge_id'
|
access_columns
|
Optional[list]
|
Edge columns from |
None
|
census_level
|
str
|
Geometry level forwarded to |
'tract'
|
census_dataset
|
str
|
|
'acs'
|
worldpop_date
|
Year (or date/datetime) forwarded to
|
None
|
|
worldpop_resolution
|
str
|
|
'1km'
|
worldpop_folder
|
Optional[str]
|
Download destination forwarded to
|
None
|
**kwargs
|
Extra keyword arguments forwarded to the underlying
|
{}
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
GeoDataFrame with one row per population polygon: |
GeoDataFrame
|
geometry, |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |