iduedu.get_intermodal_graph¶
- iduedu.get_intermodal_graph(*, osm_id=None, territory=None, clip_by_territory=False, keep_edge_geometry=True, osm_edge_tags=None, max_dist=30, keep_largest_subgraph=True, walk_kwargs=None, pt_kwargs=None)[source]¶
Build an intermodal (PT+walking) graph for a territory by downloading, parsing, and joining both networks.
The function resolves a boundary polygon (by osm_id or territory), runs in parallel: 1) pedestrian network construction (get_walk_graph), 2) public-transport network construction for selected modes (get_all_public_transport_graph), then connects PT platforms to nearby walk edges via join_pt_walk_graph using a snapping radius max_dist. Edge lengths (m) and times (min) come from the underlying builders and from the walk-edge splits.
- Parameters:
osm_id (
int | None) – OSM relation/area id for the territory; provide this or territory.territory (
Polygon | MultiPolygon | gpd.GeoDataFrame | None) – Boundary geometry in EPSG:4326.clip_by_territory (
bool) – If True, both PT and Walk graphs are clipped to the boundary.keep_edge_geometry (
bool) – If True, keep shapely geometries on edges for both sub-graphs.osm_edge_tags (
list[str] | None) – Subset of OSM tags to retain (forwarded to both builders).max_dist (
float) – Max distance in meters to connect PT platforms to walk edges.keep_largest_subgraph (
bool) – If True, keep only the largest strongly connected component after joining.walk_kwargs (
dict[str,Any] | None) – Extra keyword args for get_walk_graph (e.g., walk_speed, simplify, osm_edge_tags, keep_largest_subgraph, …). Defaults are sensible.pt_kwargs (
dict[str,Any] | None) – Extra keyword args for get_all_public_transport_graph (e.g., transport_types, osm_edge_tags, keep_edge_geometry, …).
- Returns:
- Intermodal MultiDiGraph combining public transport and pedestrian networks, with:
node attrs: x, y (local CRS), plus PT metadata for platform/station nodes where present;
edge attrs: type (e.g., “walk”, PT edge types), length_meter, time_min, optional geometry, and selected OSM tags.
Graph CRS equals the builders’ local projected CRS.
- Return type:
(nx.Graph)
Notes
keep_edge_geometry, clip_by_territory, and osm_edge_tags are propagated to both builders unless overridden in walk_kwargs/pt_kwargs.
If the PT graph is empty for the area, the function returns the walking graph alone (with a warning).
Joining requires both sub-graphs to share the same CRS; builders derive a local projected CRS from the boundary’s extent, so lengths/times are in meters/minutes.