iduedu.get_walk_graph

iduedu.get_walk_graph(*, osm_id=None, territory=None, simplify=True, clip_by_territory=False, keep_largest_subgraph=True, walk_speed=83.33333333333333, network_type='walk', custom_filter=None, osm_edge_tags=None, keep_edge_geometry=True)[source]

Build a pedestrian network (nx.MultiDiGraph) from OpenStreetMap within a given territory.

The function fetches OSM ways via Overpass using a walking filter, splits each way into directed line segments, duplicates all segments in reverse, and computes per-edge length (meters) and traversal time (minutes) using a given walking speed (m/min). Node coordinates are unique segment endpoints in a local projected CRS. Selected OSM tags can be attached to edges.

Parameters:
  • osm_id (int | None) – OSM relation/area ID for the boundary. Provide this or territory.

  • territory (Polygon | MultiPolygon | gpd.GeoDataFrame | None) – Boundary geometry (EPSG:4326) or a GeoDataFrame to define the area when osm_id is not given.

  • simplify (bool) – If True, merges contiguous segments (via internal line merging) and transfers attributes back to merged lines using nearest midpoints; if False, keeps raw per-segment edges.

  • clip_by_territory (bool) – If True, clips edges by the provided boundary before graph construction.

  • keep_largest_subgraph (bool) – If True, retains only the largest strongly connected component.

  • walk_speed (float) – Walking speed in meters per minute used to compute time_min for each edge.

  • network_type (Literal[``”walk”:py:class:`,`”custom”``]) – Preset of Overpass filters. Use “custom” together with custom_filter to pass your own way filter.

  • custom_filter (str | None) – Custom Overpass filter string used when network_type=”custom”.

  • osm_edge_tags (list[str] | None) – List of OSM edge tags to retain (overrides defaults). Only these keys are joined from element tags.

  • keep_edge_geometry (bool) – If True, stores shapely geometry on edges in the local projected CRS.

Returns:

Directed multigraph of the walking network. Each edge carries:
  • geometry (if keep_edge_geometry=True), local CRS,

  • length_meter (float), time_min (float),

  • type=”walk”,

  • selected OSM tags (as requested).

Graph attributes include: graph[“crs”] (local projected CRS), graph[“walk_speed”] (float), and graph[“type”] (network_type).

Return type:

(nx.MultiDiGraph)

Raises:

ValueError – If network_type is unknown, or network_type=”custom” without custom_filter.

Notes

All walking edges are treated as bidirectional by duplicating geometries in reverse; u/v nodes are assigned by factorizing unique segment endpoints. Lengths are measured in meters in a local projected CRS estimated from the territory bounds.