iduedu.get_drive_graph¶
- iduedu.get_drive_graph(*, osm_id=None, territory=None, simplify=True, add_road_category=True, clip_by_territory=False, keep_largest_subgraph=True, network_type='drive', custom_filter=None, osm_edge_tags=None)[source]¶
Build a drivable UrbanGraph from OpenStreetMap within a given territory.
The function downloads OSM ways via Overpass (or reads them from a local OSM file in pbf mode, see
config.set_osm_source), segments them into directed edges, optionally merges contiguous segments, normalizes OSM one-way semantics into a boolonewayedge column, and computes per-edge length (meters) and travel time (minutes). Node coordinates are unique line endpoints in a local projected CRS. Edge attributes can include selected OSM tags and a derived road category/speed.- Parameters:
osm_id (
int | None) – OSM relation/area ID of the territory boundary. Provide this orterritory.territory (
Polygon | MultiPolygon | gpd.GeoDataFrame | None) – Boundary geometry in EPSG:4326 or GeoDataFrame. Used whenosm_idis not given.simplify (
bool) – If True, merges the segments of the ways into edges that run from junction to junction. Segments are merged only when they carry the same tags, so an edge keeps the attributes of its ways, and bridges and tunnels stay separate edges. If False, keeps raw per-segment edges.add_road_category (
bool) – If True, adds a derivedcategory(e.g., local/regional/federal) and a default speed (maxspeed_mpm) inferred from the OSMhighwayclass.clip_by_territory (
bool) – If True, clips edges by the exact boundary geometry before graph construction.keep_largest_subgraph (
bool) – If True, returns only the largest strongly connected component.network_type (
Literal['drive','drive_service','custom']) – Preset of Overpass filters to select drivable ways. Use “custom” together withcustom_filterto pass your own Overpasswayfilter.custom_filter (
str | None) – Custom Overpass way filter used in custom mode.osm_edge_tags (
list[str] | None) – Which OSM tags to retain on edges. Overridesconfig.drive_useful_edges_attr(highway,name,lanes).bridgeandtunnelare always kept.oneway,maxspeedandhighwayare always read, and withsimplifya change of any of them, or of a kept tag, starts a new edge.
- Returns:
Directed multigraph of the road network. Edges include geometry in the local CRS, length, travel time, direction metadata and selected OSM tags. The graph keeps the local projected CRS and selected network type as metadata.
- Return type: