iduedu.get_all_public_transport_graph

iduedu.get_all_public_transport_graph(*, osm_id=None, territory=None, clip_by_territory=False, keep_edge_geometry=True, transport_types=None, osm_edge_tags=None)[source]

Build a combined directed graph for multiple public-transport modes within a territory.

The function collects routes for the requested modes (by default: tram, bus, trolleybus, subway), converts them into a single projected graph, and computes per-edge length and time. Edges from different modes coexist in the same nx.DiGraph; node ids are unified across modes. For the subway mode, station context is added (entrances/exits and inter-station transfers), and available station metadata is merged into node attrs.

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

  • territory (Polygon | MultiPolygon | gpd.GeoDataFrame | None) – Boundary geometry in EPSG:4326 (or a GeoDataFrame).

  • clip_by_territory (bool) – If True, clip the final graph to the boundary (in the local CRS).

  • keep_edge_geometry (bool) – If True, retain shapely geometries on edges.

  • transport_types (list[PublicTrasport] | None) – List of modes to include. Defaults to [PublicTrasport.TRAM, PublicTrasport.BUS, PublicTrasport.TROLLEYBUS, PublicTrasport.SUBWAY]. All items must be PublicTrasport enums.

  • osm_edge_tags (list[str] | None) – Which OSM tags to keep on edges/nodes. If None, a default subset from configuration is used; only these keys are joined from OSM.

Returns:

Combined directed PT graph. Typical attributes:
  • node attrs: x, y (local CRS), type, route, ref_id, station extra_data where applicable;

  • edge attrs: type, route, length_meter, time_min, optional geometry, plus selected OSM tags.

Graph attrs: graph[“crs”] (EPSG int), graph[“type”] = “public_trasport”.

Return type:

(nx.DiGraph)

Notes

Each mode’s ways are downloaded inside the boundary and transformed into directed edges; per-edge speeds are taken from mode-specific defaults (and, for subway connectors, from connector-type defaults).