Coverage zones

This notebook builds coverage zones of the example services on an intermodal UrbanGraph: every place is assigned to the service it reaches at the lowest network cost within a budget, so zones do not overlap. It shows

  • get_graph_coverage by distance (800 m) and by time (10 min);

  • get_stepped_graph_coverage in bands of 2 minutes, as Voronoi cells and as separate buffers;

  • the graph-free get_radius_coverage.

The method is described on the coverage page. The interactive maps show a light copy of every result (for_map: outlines simplified by 2 m), which keeps the notebook small.

The last section, Your own area, shows what to replace to get the same pictures for another territory.

# Install required packages (uncomment if needed)
# !pip install iduedu pyarrow objectnat
import geopandas as gpd
import iduedu
from iduedu import get_4326_boundary, get_intermodal_graph

from objectnat import get_graph_coverage, get_radius_coverage, get_stepped_graph_coverage
import folium


def for_map(gdf, tolerance=2.0):
    """A light copy for a web map: outlines simplified by `tolerance` metres, coordinates rounded to about 10 cm."""
    local = gdf.to_crs(gdf.estimate_utm_crs())
    local["geometry"] = local.simplify(tolerance)
    light = local.to_crs(4326)
    light["geometry"] = light.geometry.set_precision(1e-6)
    return light[~light.is_empty]

def grey_tiles():
    """Light grey base map (Esri World Light Gray); its tiles end at zoom 16 and are stretched beyond it."""
    return folium.TileLayer("Esri.WorldGrayCanvas", max_zoom=19, max_native_zoom=16)

1. Intermodal graph

# Vasilyevsky Island district, Saint Petersburg (OSM relation 1114252).
# IduEdu cuts the territory out of the Geofabrik extract (pip install "iduedu[pbf]");
# without the `with` block the same calls query the Overpass API.
with iduedu.use_pbf(osm_id=1114252, region="northwestern-fed-district"):
    poly = get_4326_boundary(osm_id=1114252)
    G_intermodal = get_intermodal_graph(territory=poly, clip_by_territory=True)
2026-11-06 19:16:01.201 | WARNING  | iduedu.graph.transformers:keep_largest_connected_component:64 - Removing 338 nodes outside the largest strongly connected component. Retaining 21181 of 21519 nodes.
2026-11-06 19:16:01.224 | WARNING  | iduedu.graph_builders.intermodal_builders:join_pt_walk_graph:248 - Public transport nodes dropped with the smaller components: {'trolleybus': 2}

2. Services

36 services with a name and a capacity column (EPSG:32636).

services = gpd.read_parquet('examples_data/services.parquet')

3. Coverage by distance

Zones within 800 m of network distance (weight_type="length_meter").

# Calculate coverage zones by distance (800m cutoff)
result_length = get_graph_coverage(
    G_intermodal,
    gdf_destinations=services,
    weight_type="length_meter",
    weight_value_cutoff=800,
)

# Coverage results are indexed like the input services. Join service attributes
# back by index before coloring or filtering by service columns such as "name".
result_length = result_length.join(services[['name']], how="left")

# Visualize results
for_map(result_length).explore(column='name', legend=False, tiles=grey_tiles())
Make this Notebook Trusted to load map: File -> Trust Notebook

4. Coverage by time

Zones within 10 minutes (weight_type="time_min"), clipped to the district boundary with zone.

# Prepare zone boundary
zone = gpd.GeoDataFrame(geometry=[poly], crs=4326)

# Calculate coverage zones by time (10min cutoff)
result_time = get_graph_coverage(
    G_intermodal,
    gdf_destinations=services,
    weight_type="time_min",
    weight_value_cutoff=10,
    zone=zone,
)

# Coverage results preserve the input service index, so service attributes can
# be joined back by index for visualization.
result_time = result_time.join(services[['name']], how="left")

# Visualize results
for_map(result_time).explore(column='name', legend=False, tiles=grey_tiles())
Make this Notebook Trusted to load map: File -> Trust Notebook

Parameters used

  • weight_type: "length_meter" (metres) or "time_min" (minutes);

  • weight_value_cutoff: the budget, in the units of weight_type;

  • zone (optional): polygon the zones are clipped to; without it they are clipped to the concave hull of the reachable nodes;

  • geometry_type (optional): "radius" or "ways" additionally clips the zones to residual-distance buffers or to the buffered streets.

5. Stepped coverage by time

The covered area split into bands of 2 minutes up to 15 minutes, with two values of geometry_type:

  • None: Voronoi cells of the graph nodes;

  • "separate": independent buffers per band, without Voronoi cells.

"radius" and "ways" clip the same Voronoi bands to the residual-distance buffers or to the buffered streets, as in the isochrones notebook.

stepped_cov_voronoi = get_stepped_graph_coverage(
    G_intermodal,
    gdf_destinations=services,
    weight_type="time_min",
    geometry_type=None,
    weight_value_cutoff=15,
    step=2,
    zone=zone,
)
# Visualize stepped coverage
for_map(stepped_cov_voronoi).explore(column='dist', tiles=grey_tiles())
Make this Notebook Trusted to load map: File -> Trust Notebook
stepped_cov_separate = get_stepped_graph_coverage(
    G_intermodal,
    gdf_destinations=services,
    weight_type="time_min",
    geometry_type='separate',
    weight_value_cutoff=15,
    step=2,
)
# Visualize stepped coverage
for_map(stepped_cov_separate).explore(column='dist', tiles=grey_tiles(), vmin=0)
Make this Notebook Trusted to load map: File -> Trust Notebook

6. Radius coverage

Without a graph: Voronoi polygons of the services clipped to 500 m buffers.

radius_cov = get_radius_coverage(gdf_from=services[['name','geometry']], radius=500)
# Visualize radius coverage
for_map(radius_cov).explore(column='name', legend=False, tiles=grey_tiles())
Make this Notebook Trusted to load map: File -> Trust Notebook

7. Your own area

The territory is an OSM relation (the relation of a district or a city on openstreetmap.org); REGION names the Geofabrik extract to cut it from (iduedu.find_geofabrik_region finds it for a polygon; without it IduEdu asks Overpass once to choose the extract). The result is a GeoDataFrame: draw it with matplotlib (here over the streets of the graph, with the territory boundary), explore it on a web map or save it for GIS with to_file.

import matplotlib.pyplot as plt

OSM_ID, REGION = 1114252, "northwestern-fed-district"  # your territory
my_services = services  # your services: points in any CRS

with iduedu.use_pbf(osm_id=OSM_ID, region=REGION):  # downloaded once, then cached
    my_boundary = get_4326_boundary(osm_id=OSM_ID)
    my_graph = get_intermodal_graph(territory=my_boundary, clip_by_territory=True)
my_bands = get_stepped_graph_coverage(
    my_graph, gdf_destinations=my_services, weight_type="time_min", weight_value_cutoff=15, step=2,
    zone=gpd.GeoDataFrame(geometry=[my_boundary], crs=4326),
)

local = my_bands.to_crs(my_graph.nodes_gdf.crs)
streets = my_graph.edges_gdf[my_graph.edges_gdf["type"] == "walk"]  # the street network as the background
ax = streets.plot(color="#c2c2c2", linewidth=0.3, figsize=(9, 6))
local.plot(ax=ax, column="dist", cmap="YlGnBu_r", alpha=0.85, legend=True,
           legend_kwds={"label": "time to the nearest service, min"})
gpd.GeoSeries([my_boundary], crs=4326).to_crs(local.crs).boundary.plot(ax=ax, color="#3d3d3d", linewidth=1)
my_services.to_crs(local.crs).plot(ax=ax, color="#1f2d4d", markersize=14, edgecolor="white", zorder=5)
ax.set_axis_off()
plt.show()
# my_bands.to_file("my_coverage.gpkg")  # for GIS
2026-11-06 19:16:16.427 | WARNING  | iduedu.graph.transformers:keep_largest_connected_component:64 - Removing 338 nodes outside the largest strongly connected component. Retaining 21181 of 21519 nodes.
2026-11-06 19:16:16.458 | WARNING  | iduedu.graph_builders.intermodal_builders:join_pt_walk_graph:248 - Public transport nodes dropped with the smaller components: {'trolleybus': 2}
../../_images/b853d44b3e98e2c373529b73c462c671d459d76461ed2bbbda02580cc4f86ea9.png
for_map(my_bands).explore(column="dist", cmap="YlGnBu_r", tiles=grey_tiles())
Make this Notebook Trusted to load map: File -> Trust Notebook