Skip to content

UrbanAccessAnalyzer

UrbanAccessAnalyzer: street networks from OpenStreetMap and access scores to points of interest.

The four main classes, used in this order:

  • :class:AreaOfInterest -- the study area (geocoded by name or read from a file);
  • :class:StreetNetwork -- the walk / bike / drive network of that area, built from an .osm.pbf file;
  • :class:PointsOfInterest -- schools, stops, shops... from OpenStreetMap or your own table, with a score;
  • :class:AccessibilityAnalyzer -- how well each street, node or H3 cell reaches those points within given distances.

AreaOfInterest(gdf)

A geographic area of interest, backing every other class's spatial extent.

Wrap an existing AOI GeoDataFrame.

Prefer :meth:from_name or :meth:from_file over calling this directly.

Parameters:

Name Type Description Default
gdf GeoDataFrame

AOI geometry, any CRS.

required

from_name(name, buffer=0.0) classmethod

Geocode a place name into an AOI via Nominatim.

Parameters:

Name Type Description Default
name str

Place name/query, e.g. "Cambridge, MA".

required
buffer float

Optional buffer (meters, applied in local UTM) around the geocoded geometry.

0.0

Returns:

Type Description
'AreaOfInterest'

A new :class:AreaOfInterest.

from_file(path, bounds=None) classmethod

Load an AOI from any vector file format.

Parameters:

Name Type Description Default
path str

File path (see :func:UrbanAccessAnalyzer.geometry_ops.read_geofile for supported formats).

required
bounds

Optional bbox filter.

None

Returns:

Type Description
'AreaOfInterest'

A new :class:AreaOfInterest.

plot(m=None, **kwargs)

Draw this AOI's outline on a Folium map.

Parameters:

Name Type Description Default
m

Existing folium.Map to draw onto; a new one is created if omitted.

None
**kwargs

Passed through to :func:UrbanAccessAnalyzer.plotting.general_map.

{}

Returns:

Type Description

The folium.Map.

StreetNetwork(nodes, edges, crs)

A street network for routing, backed by Polars node/edge tables.

Internally just two Polars DataFrames (nodes, edges) in a projected metric CRS -- see :mod:UrbanAccessAnalyzer.osm_io and :mod:UrbanAccessAnalyzer.graph_ops for how they're built and manipulated. No networkx/osmnx graph object exists anywhere in this class.

from_pbf(pbf_path, aoi=None, network_type='walk', simplify_distance=None, ignore_oneway=False, crop_buffer_m=500.0) classmethod

Build a street network from a local (or Geofabrik-downloaded) PBF file.

Parameters:

Name Type Description Default
pbf_path str

Path to a .osm.pbf file. If it doesn't exist and aoi is given, it's downloaded from Geofabrik first (:func:UrbanAccessAnalyzer.osm_io.download_geofabrik).

required
aoi Optional[AreaOfInterest]

AOI used both for downloading (if needed) and for bbox prefiltering during load.

None
network_type str

One of "walk", "bike", "drive", "all", "walk+bike", "walk+bike+primary".

'walk'
simplify_distance Optional[float]

If given, run :func:UrbanAccessAnalyzer.graph_ops.simplify with this cluster distance (meters) right after loading.

None
ignore_oneway bool

Forwarded to :func:UrbanAccessAnalyzer.osm_io.load_pbf -- if True, every kept way gets edges in both directions regardless of its OSM oneway tag (see that function's docstring). network_type="walk" already ignores oneway unconditionally; this only matters for other profiles (e.g. "all") used for walking-access purposes.

False
crop_buffer_m float

Metres to buffer aoi by before cropping the network to it (2026-09-04, explicit user request: "crop_by_ aoi_connected here you should use the aoi with a buffer" -- a buffer is only ever for avoiding a stop-cropping/network- boundary effect, never for anything population-related, which stays on the real unbuffered AOI elsewhere in the pipeline). Cropping a street network to the EXACT AOI edge can cut a real street mid-block right at the boundary, producing an artificial dead end and, in the worst case, stranding an otherwise-real stop/destination just outside the crop -- a small buffer keeps a margin of real network around the AOI so nothing legitimate right at the edge gets severed. Set to 0 for the old exact-AOI behavior.

500.0

Returns:

Type Description
'StreetNetwork'

A new :class:StreetNetwork, projected to a local UTM CRS.

simplify(cluster_distance, protected_node_ids=None)

Cluster-simplify this network's topology; see :func:UrbanAccessAnalyzer.graph_ops.simplify.

Parameters:

Name Type Description Default
cluster_distance float

Max edge length used to chain nodes into a cluster.

required
protected_node_ids Optional[list[int]]

Node ids to keep as singleton clusters.

None

Returns:

Type Description
'StreetNetwork'

A new, simplified :class:StreetNetwork.

crop(aoi, crop_buffer_m=500.0)

Crop this network to an AOI; see :func:UrbanAccessAnalyzer.graph_ops.crop_by_aoi_connected.

Parameters:

Name Type Description Default
aoi AreaOfInterest

Area to crop to.

required
crop_buffer_m float

Metres to buffer aoi by first -- see :meth:from_pbf's crop_buffer_m docstring (a buffer is only ever for avoiding a network-boundary effect, never for anything population-related). 0 for the exact-AOI behavior.

500.0

snap_points(points, max_dist=None, min_edge_length=1.0)

Snap POI points onto this network, splitting edges as needed.

Parameters:

Name Type Description Default
points 'PointsOfInterest'

Points to snap. Reprojected to this network's CRS first if points.crs is set and differs from it (e.g. POIs fetched via :meth:PointsOfInterest.from_overpass, which are always EPSG:4326, snapped onto a network in a projected UTM CRS).

required
max_dist Optional[float]

Maximum snap distance.

None
min_edge_length float

See :func:UrbanAccessAnalyzer.graph_ops.snap_points.

1.0

Returns:

Type Description

Tuple (StreetNetwork, points_with_node_id) -- the updated

network and points.df with a new node_id column.

to_gdf()

Export edges as a GeoDataFrame.

save(folder)

Persist nodes/edges as Parquet.

Parameters:

Name Type Description Default
folder str

Destination directory (created if missing). Writes nodes.parquet, edges.parquet, and a small meta.txt with the CRS.

required

load(folder) classmethod

Load a network previously written by :meth:save.

Parameters:

Name Type Description Default
folder str

Folder written by :meth:save (nodes.parquet, edges.parquet, meta.txt).

required

Returns:

Type Description
'StreetNetwork'

The loaded network.

plot(m=None, **kwargs)

Draw this network's edges on a Folium map.

Parameters:

Name Type Description Default
m

Existing Folium map to draw on; None creates one.

None
**kwargs

Passed to :func:UrbanAccessAnalyzer.plotting.general_map.

{}

Returns:

Type Description

The Folium map.

PointsOfInterest(df, crs=None)

A set of scored points of interest, backed by a Polars DataFrame with WKB geometry.

Wrap an existing POI DataFrame.

Parameters:

Name Type Description Default
df DataFrame

POI table with a WKB geometry column, and any tag/score columns.

required
crs Optional[str]

CRS of df's geometry column, e.g. "EPSG:4326". Optional and None by default (e.g. when a caller builds points directly in a street network's own projected CRS, as the test suite does) -- but set it whenever the geometry's CRS is known and may differ from the network it will be run against, so :meth:StreetNetwork.snap_points and :meth:AccessibilityAnalyzer.run can reproject correctly instead of silently mixing coordinate systems.

None

from_overpass(kind, bounds) classmethod

Fetch a named OSM POI category via Overpass.

Parameters:

Name Type Description Default
kind str

One of the convenience functions in :mod:UrbanAccessAnalyzer.osm_io: "schools", "healthcare", "groceries", "shops", "restaurants", "libraries", "pharmacies", "gyms", "cinemas", "bus_stops", "green_areas".

required
bounds GeoDataFrame

AOI GeoDataFrame defining the query extent.

required

Returns:

Type Description
'PointsOfInterest'

A new :class:PointsOfInterest, with geometry in EPSG:4326 (see

'PointsOfInterest'

func:UrbanAccessAnalyzer.osm_io.overpass_query).

Raises:

Type Description
ValueError

For an unrecognized kind.

assign_score_by_values(column, value_priority, out_column='poi_score')

Assign a [0, 1] score from a categorical column; see :func:UrbanAccessAnalyzer.scoring.score_by_values.

Parameters:

Name Type Description Default
column str

Categorical column to score.

required
value_priority list

Values from best to worst; the best gets score 1.

required
out_column str

Name of the new score column.

'poi_score'

Returns:

Type Description
'PointsOfInterest'

A new :class:PointsOfInterest with the score column.

to_h3(resolution, columns=None, method='max')

Rasterize these points to H3 cells; see :func:UrbanAccessAnalyzer.h3_ops.from_df.

Parameters:

Name Type Description Default
resolution int

H3 resolution.

required
columns Optional[list]

Columns to carry onto the cells; None = all.

None
method Union[str, dict]

How several points in one cell combine ("max", "sum", ... or {column: method}).

'max'

Returns:

Type Description
DataFrame

One row per H3 cell.

to_gdf()

Export as a GeoDataFrame, in self.crs (EPSG:4326 if unset).

AccessibilityAnalyzer(street_network, points)

Orchestrates a :class:StreetNetwork + :class:PointsOfInterest into isochrones.

default_distance_matrix(distance_steps, poi_score_col='poi_score', score_bins=None)

See :func:UrbanAccessAnalyzer.isochrones.default_distance_matrix.

Parameters:

Name Type Description Default
distance_steps Sequence[float]

Walking distances (m) of the access levels, from best to worst.

required
poi_score_col str

POI score column.

'poi_score'
score_bins Optional[int]

Number of score bins; None = one per distinct score.

None

Returns:

Type Description

The distance matrix (score bins x access levels).

run(distance_matrix, poi_score_col='poi_score', access_score_values=None, min_edge_length=1.0, max_dist=None, undirected=True, verbose=True, unreached_access_score=0.0, chunk_h3_resolution=None, chunk_buffer_m=1000.0)

Compute the multi-tier access-score isochrone; see :func:UrbanAccessAnalyzer.isochrones.graph.

Parameters:

Name Type Description Default
distance_matrix

See :func:UrbanAccessAnalyzer.isochrones.distance_matrix_to_processing_order.

required
poi_score_col Optional[str]

Score column on self.points.df. Pass None if every POI should be treated as a single undifferentiated tier (then distance_matrix is just a list of distances).

'poi_score'
access_score_values Optional[Sequence]

Explicit access-score labels, positionally aligned with distance_matrix (access_score_values[i] is the score awarded within distance_matrix[i]). Only meaningful when distance_matrix is a plain list of distances -- ignored when it's already a labeled matrix DataFrame.

None
min_edge_length float

Minimum snap/split segment length (meters).

1.0
max_dist Optional[float]

Maximum POI-to-edge snap distance (meters).

None
undirected bool

Ignore one-way restrictions during the search.

True
verbose bool

Print per-tier progress.

True
unreached_access_score Optional[float]

Score given to the parts of the network no POI reaches. Defaults to 0.0 so both returned tables cover the whole network -- every node and every edge, scored 0 where there is no access instead of being omitted. Set to None to get only the reached subset (the pre-2026-08-13 behaviour); automatically ignored for categorical access-score labels, which have no meaningful zero. See :func:UrbanAccessAnalyzer.isochrones.exact_edge_access.

0.0
chunk_h3_resolution Optional[int]

If set, computes node access in memory-bounded H3-res-N chunks instead of one whole-network pass -- see :func:UrbanAccessAnalyzer.isochrones.compute_node_access_chunked. Opt-in; None (default) is the original, unaffected behavior.

None
chunk_buffer_m float

Buffer (meters) forwarded when chunk_h3_resolution is set. Must be >= the largest distance in distance_matrix.

1000.0

Returns:

Type Description
DataFrame

Tuple (node_access, edge_access) Polars DataFrames -- see

DataFrame

func:UrbanAccessAnalyzer.isochrones.graph.

to_gdf(edge_access=None)

Export the last (or given) edge-access result as a street-edges GeoDataFrame.

Parameters:

Name Type Description Default
edge_access Optional[DataFrame]

Result of :meth:run; defaults to the most recent call.

None

Returns:

Type Description
GeoDataFrame

GeoDataFrame of scored edge segments, in the street network's CRS.

to_level(level_gdf, id_col, edge_access=None, columns=None, agg=None)

Aggregate the last (or given) edge-access result onto an arbitrary polygon layer.

Generalizes :meth:to_h3 to any polygon GeoDataFrame (an H3 grid, administrative boundaries, or any other polygon layer), via :func:UrbanAccessAnalyzer.geometry_levels.edges_to_level (which in turn requires the optional geohierarchy dependency).

Parameters:

Name Type Description Default
level_gdf GeoDataFrame

Target polygon GeoDataFrame to aggregate onto.

required
id_col str

Name of the unique id column in level_gdf.

required
edge_access Optional[DataFrame]

Result of :meth:run; defaults to the most recent call.

None
columns Optional[list]

Attribute columns to aggregate; defaults to ["access_score"].

None
agg

Aggregation strategy (a :class:~geohierarchy.aggregation.AggregationStrategy instance, or a per-column mapping); defaults to :class:~geohierarchy.aggregation.Mean for every column.

None

Returns:

Type Description
GeoDataFrame

A copy of level_gdf with id_col, geometry, and the

GeoDataFrame

aggregated columns -- one row per polygon.

to_h3(resolution, edge_access=None, method='max')

Rasterize the last (or given) edge-access result to H3 cells.

Thin convenience wrapper: builds an H3 grid over the edges' extent via the optional geohierarchy dependency's :func:~geohierarchy.h3_cells, then delegates to :meth:to_level.

Parameters:

Name Type Description Default
resolution int

H3 resolution.

required
edge_access Optional[DataFrame]

Result of :meth:run; defaults to the most recent call.

None
method str

Aggregation method for access_score: "max", "min", "mean", or "sum".

'max'

Returns:

Type Description
DataFrame

Polars DataFrame with an "h3" cell-id column and an

DataFrame

aggregated access_score column.