iduedu.get_bike_graph¶
- iduedu.get_bike_graph(*, osm_id=None, territory=None, simplify=True, clip_by_territory=False, keep_largest_subgraph=True, bike_speed=250.0, max_lts=None, allow_footways=False, elevation=None, network_type='bike', custom_filter=None, osm_edge_tags=None)[source]¶
Build a cycling UrbanGraph from OpenStreetMap within a given territory.
The graph holds every way a bicycle may use: streets (except motorways and ways closed to bicycles), cycleways, paths and tracks, and footways and pedestrian streets where cycling is permitted (
bicycle=yes,designatedorpermissive). Every edge gets the kind of cycling infrastructure (cycle_infra:track,laneormixed) and the level of traffic stress (lts, 1 to 4, seelevel_of_traffic_stress()).The graph is directed. One-way streets are one-way for bicycles too, unless the way allows riding against the traffic (
oneway:bicycle=noor acycleway*=opposite*tag). Travel time is the length overbike_speed; withelevationit also depends on the grade.- 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.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.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.bike_speed (
float) – Cycling speed on flat ground in meters per minute.max_lts (
int | None) – Keep only edges with a level of traffic stress up to this one, for example 2 for the network that most adults are willing to ride.allow_footways (
bool) – If True, footways and pedestrian streets are used also without an explicitbicyclepermission.elevation (
Union[str,PathLike,GeoDataFrame,Callable,None]) – Source of heights foradd_elevation()(a raster path, a GeoDataFrame of points or contours, or a function). When given, edges get grades, and travel times are rescaled with the cycling speed model ofapply_grade_speed().network_type (
Literal['bike','custom']) –"bike", or"custom"together withcustom_filter.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.bike_useful_edges_attr(highway,name,lanes,maxspeed,surface).bridgeandtunnelare always kept. Thecycleway*,bicycle,onewayandoneway:bicycletags are always read, and withsimplifya change of any of them, or of a kept tag, starts a new edge.
- Returns:
Directed multigraph of the cycling network. Edges include geometry in the local CRS,
length_meter,time_min,oneway,cycle_infra,lts, the selected OSM tags and, withelevation,grade,grade_max,ascentanddescent.- Return type:
- Raises:
ValueError – If
max_ltsis not between 1 and 4, or the network type is unknown.