transitlos.level_of_service¶
Orchestrates network + stops + scoring into a street-edges level_of_service GeoDataFrame.
Pipeline: network.prepare_street_network (if network not given) +
stops.download_and_prepare_stops (if stops not given) +
stop_scores.compute_stop_scores (if stops lacks a stop_score column
yet) feed a UrbanAccessAnalyzer.api.PointsOfInterest (transit stops, scored
by stop_score) into an AccessibilityAnalyzer, whose .run() + .to_gdf()
produce the final street-edges level_of_service GeoDataFrame.
2026-08-12 rewrite, at the user's explicit request: this module used to
rely on AccessibilityAnalyzer.default_distance_matrix's own generic
rank-based falloff, deliberately not calling transitlos.scoring's own
walk_decay/accessibility_score to avoid double-counting walk decay (once
via that generic falloff, once via walk_decay). That tradeoff is now
resolved the other way: transitlos.scoring.distance_matrix
.build_intelligent_distance_matrix builds the distance_matrix argument
AccessibilityAnalyzer.run expects from transitlos.scoring's own
offset-power D(t; stop_score) decay (see walk_access.py), so the
isochrone engine now runs transitLOS's own decay directly --
there is no longer a second, independent falloff to double-count against.
This also implements "intelligent discretization" (see
distance_matrix.py's module docstring for the full rationale):
- Distance steps are no longer a flat convention (the old
walk_distance_steps=(400, 800, 1200)default) -- they are derived by inverting the decay curve at each output-grid tier's midpoint, so every isochrone distance computed maps directly onto an output-visible{0.0, 0.1, ..., 1.0}boundary. - Stops are grouped ("bucketed") by output-equivalent stop_score, not
left as hundreds of near-duplicate continuous values -- two stops whose
stop_scorewould produce identical ceiling-discretized output at every chosen distance collapse into one distance-matrix row, directly minimizing the number of(poi_score, distance)isochrone/Dijkstra runsUrbanAccessAnalyzer.isochroneshas to perform (that module already batches every POI sharing a tier into one multi-source search -- see its docstring -- so fewer distinct tiers is exactly fewer runs). - The final
level_of_serviceis ceiling-discretized onto{0.0, 0.1, ..., 1.0}both inside the matrix and, as a safety net, on the final per-edge output column (UrbanAccessAnalyzer'sexact_edge_accesscan produce edge-interpolated values between matrix grid points that a matrix-only discretization wouldn't catch).
walk_distance_steps remains an accepted parameter for backward
compatibility and manual overrides, but is no longer used by default --
compute_level_of_service only falls back to it if
build_intelligent_distance_matrix is explicitly bypassed (region=None
is not a valid escape hatch here; pass distance_matrix/bucket_map
yourself if you need the old flat-convention behavior).
compute_level_of_service(aoi, feed_source=None, network=None, stops=None, region='global', cache_dir=None, walk_distance_steps=(400, 800, 1200), weights=None, pbf_path=None, date_range=None, score_bins=50, max_walk_distance_m=None, chunk_h3_resolution=None, chunk_buffer_m=1000.0, stops_crop_buffer_m=500.0, **stops_kwargs)
¶
Compute a street-edges GeoDataFrame with a transit-access level_of_service column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
aoi
|
AreaOfInterest
|
Area of interest for the network and (if |
required |
feed_source
|
GTFS feed source forwarded to
|
None
|
|
network
|
Optional[StreetNetwork]
|
A pre-built |
None
|
stops
|
Optional[GeoDataFrame]
|
A pre-built stops GeoDataFrame; if |
None
|
region
|
str
|
Region key forwarded to |
'global'
|
cache_dir
|
Optional[str]
|
Passed to |
None
|
walk_distance_steps
|
Sequence[float]
|
Deprecated/unused by default as of
2026-08-12 -- distance thresholds are now derived automatically
by |
(400, 800, 1200)
|
weights
|
Optional[tuple[float, float, float]]
|
Optional |
None
|
pbf_path
|
Optional[str]
|
Passed to |
None
|
date_range
|
Optional[tuple[Union[date, datetime], Union[date, datetime]]]
|
Optional |
None
|
score_bins
|
Optional[int]
|
Deprecated/unused by default as of 2026-08-12 --
|
50
|
max_walk_distance_m
|
Optional[float]
|
Optional hard outer walk-distance cutoff
(meters) forwarded to |
None
|
chunk_h3_resolution
|
Optional[int]
|
Opt-in memory-bounded isochrone computation --
forwarded to |
None
|
chunk_buffer_m
|
float
|
Forwarded as |
1000.0
|
stops_crop_buffer_m
|
float
|
Metres to buffer |
500.0
|
**stops_kwargs
|
Extra keyword arguments forwarded to
|
{}
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
|
GeoDataFrame
|
|
GeoDataFrame
|
1.0}` internally (see module docstring, point 3) and then rescaled |
GeoDataFrame
|
to |
GeoDataFrame
|
every 0-1 score be displayed/stored on a 0-100 scale. |