iduedu.get_public_transport_graph¶
- iduedu.get_public_transport_graph(*, osm_id=None, territory=None, transport_types=None, clip_by_territory=False, osm_edge_tags=None, transport_registry=None, crs=None)[source]¶
Build a directed public-transport graph for one or multiple transport modes within a territory.
The function resolves a boundary (by
osm_idorterritory), downloads OpenStreetMap public-transport routes inside that boundary, converts them into a projectedUrbanGraph, and computes per-edge length (meters) and travel time (minutes). Multiple modes can coexist in the same graph; node ids are unified across modes.For the
subwaymode, additional station context may be added (entrances/exits and inter-station transfers), and available station metadata may be merged into node attributes.- Parameters:
osm_id (
int|None) – OSM relation/area id of the territory. Provide this orterritory.territory (
Polygon|MultiPolygon|GeoDataFrame|None) – Boundary geometry in EPSG:4326 (or a GeoDataFrame). Used whenosm_idis not given.transport_types (
str|list[str] |None) –- Transport mode(s) to include. Accepts:
None: include every mode oftransport_registry;str: a single OSM route type, e.g."bus";Sequence[str]: multiple types, e.g.["tram", "bus", "trolleybus", "subway"].
Values are normalized with
strip().lower()and validated against the registry.clip_by_territory (
bool) – If True, clip the resulting graph to the boundary (in the local CRS).osm_edge_tags (
list[str] |None) – Subset of OSM tags to retain on edges/nodes. If None, a default subset is used.transport_registry (
TransportRegistry|None) – Transport registry used to validate transport types and to compute per-edge travel times (via each mode’s parameters such as free speed, acceleration and braking distances, dwell time and average waiting time for boarding edges). If None,DEFAULT_REGISTRYis used.crs (
Any|None) – Projected CRS in metres for the graph (anythingpyproj.CRS.from_user_inputaccepts). If None, the UTM zone of the territory is estimated. Give one CRS to graphs built in parts to share coordinates, or a conformal CRS of a large area (such as a Lambert conic) when routes reach far beyond one UTM zone.
- Return type:
- Returns:
Directed PT
UrbanGraphwithcrsandtype="public_transport". Route stops and the edges of a route carry itsroute_key(osm:r<relation id>), platforms the list of keys of the routes calling there, andgraph.routesis the table of the routes:mode, the relation tags ofconfig.transport_route_attr,osm_id,osm_routeand theroute_masterline asline_keyandline_name. Withclip_by_territoryit keeps the routes with an edge inside.