UrbanAccessAnalyzer.grading¶
Grade street accessibility to several types of points of interest (POIs).
Each POI type is described by a small config dict::
{
"name": "groceries", # label, also the output column name
"query": osm_io.groceries, # callable(bounds) -> POI table, see osm_io
"geometry": "Point", # "Point" or "Polygon" (e.g. parks)
"importance": 8, # relative weight in the final score
"max_distance": 1500, # meters walked beyond which the POI is worthless
"icon": "🛒", # optional emoji shown on the maps
}
query can be an OSM query (:mod:UrbanAccessAnalyzer.osm_io,
:func:UrbanAccessAnalyzer.osm_io.tag_query) or your own file
(:func:query_from_file).
Grading, per POI type:
- Distances
max_distance * j / n_steps(j = 1..n_steps) are the walk-distance tiers; the score of a street node is100 * (n_steps - j + 1) / n_stepsfor the closest tier it falls in (so100right next to a POI and100 / n_stepsatmax_distance), and0beyondmax_distance. PointPOIs are snapped onto the street network.PolygonPOIs (parks) enter the network wherever their boundary touches a street, and every node inside the polygon scores100.
The final score of a node is the importance-weighted mean of its per-type scores; an edge takes the mean of its two end nodes.
query_from_file(path, name_column=None)
¶
Build a POI query from your own vector file (points or polygons).
Any format GeoPandas reads works: GeoPackage, GeoJSON, Shapefile, GeoParquet, FlatGeobuf, ... in any CRS. Only the features inside the download area are kept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the file. |
required |
name_column
|
Optional[str]
|
Column with the POI names (shown on the maps), if any. |
None
|
Returns:
| Type | Description |
|---|---|
Callable
|
A function |
fetch_pois(specs, bounds, crs, max_retries=3, retry_wait=5.0)
¶
Run every config's query over bounds and return one GeoDataFrame per POI type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
specs
|
Sequence[dict]
|
POI configs (see module docstring). |
required |
bounds
|
GeoDataFrame
|
Download area. |
required |
crs
|
CRS to project the results to (normally |
required | |
max_retries
|
int
|
Attempts per query (public Overpass servers are often busy). |
3
|
retry_wait
|
float
|
Seconds between attempts. |
5.0
|
Returns:
| Type | Description |
|---|---|
dict[str, GeoDataFrame]
|
|
dict[str, GeoDataFrame]
|
per feature; |
dict[str, GeoDataFrame]
|
query fails or returns nothing maps to an empty GeoDataFrame. |
grade(network, specs, pois, n_steps=5, max_snap_dist=150.0, min_edge_length=30.0, score_col='access_score')
¶
Grade every street edge by its walk distance to each POI type, then combine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
network
|
StreetNetwork
|
Street network (projected CRS, meters). |
required |
specs
|
Sequence[dict]
|
POI configs (see module docstring). |
required |
pois
|
dict[str, GeoDataFrame]
|
Output of :func: |
required |
n_steps
|
int
|
Number of distance tiers per POI type. |
5
|
max_snap_dist
|
Optional[float]
|
Max distance (m) from a POI to the nearest street. |
150.0
|
min_edge_length
|
float
|
Minimum edge length (m) created when snapping POIs. |
30.0
|
score_col
|
str
|
Name of the combined |
'access_score'
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
|
StreetNetwork
|
edge with one |
tuple[GeoDataFrame, StreetNetwork]
|
importance-weighted |
poi_table(specs, pois)
¶
One EPSG:4326 table of all POIs for mapping, with columns type, name, icon.
icon is the config's optional "icon" emoji (default "📍"), which
:func:UrbanAccessAnalyzer.plotting.general_map draws on each POI
(poi_column="type", poi_icon_column="icon").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
specs
|
Sequence[dict]
|
The POI configs (each with |
required |
pois
|
dict[str, GeoDataFrame]
|
|
required |
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
One GeoDataFrame in EPSG:4326 with |