IduEdu

Multimodal city networks from OpenStreetMap and GTFS

IduEdu is an open-source Python library that builds street, cycling, public-transport and intermodal networks of a city from OpenStreetMap and GTFS Schedule feeds, routes on them and measures them. It is developed by the IDU team at ITMO University.

Code style: black PyPI version Tests and coverage Coverage License GitHub


Overview

Every network is an UrbanGraph: a table of nodes and a table of edges (GeoDataFrames in a local metric CRS) with the edge costs length_meter (metres) and time_min (minutes). The graph algorithms run in parallel threads in a compiled Rust extension, iduedu._rust. Every page below describes what is computed, the method, the parameters and outputs with their units, figures and the limitations.

Topic

Result

Functions

Data sources

OSM data from the Overpass API or from a local .osm.pbf file, downloaded from Geofabrik and cut to the territory

use_pbf(), download_osm_pbf(), split_by_polygons()

Streets: drive, walk and bike

Walk, drive and bike graphs with travel times, kept OSM tags, bridges and tunnels, cycling stress levels

get_walk_graph(), get_drive_graph(), get_bike_graph()

Public transport from OpenStreetMap

Bus, trolleybus, tram, subway, monorail and train routes from OSM, timed by a speed model per mode

get_public_transport_graph(), TransportRegistry

Public transport from GTFS

Public transport from GTFS Schedule feeds, with waiting times from the timetable

get_gtfs_public_transport_graph(), merge_gtfs_feeds()

Intermodal graphs

Walking and public transport in one graph, joined at platforms and station entrances

get_intermodal_graph(), join_pt_walk_graph()

The UrbanGraph model

The graph model: node and edge tables, types, validation, storage, NetworkX

UrbanGraph, read_urban_graph()

Graph operations

Clipping, subgraphs, joins, components, merged junctions, objects projected onto edges

clip_urban_graph(), project_objects2urban_graph()

Shortest paths and matrices

Costs and routes from one or many sources, origin–destination matrices

od_matrix(), single_source_dijkstra()

Routes between two points

One route by bidirectional search, A* or ALT; alternative routes; k shortest routes

shortest_path(), alternative_paths(), k_shortest_paths()

Network statistics

Length, density, junctions and directness of a network, by area or zone

graph_stats(), local_stats()

Objects around origins

Nearest objects, counts and sums of objects within a travel cost, diversity

aggregate_objects(), nearest_objects()

Centrality

Reach, closeness, gravity and betweenness of nodes and edges

centrality(), edge_betweenness()

Flow assignment

Trips from sources spread over destinations and summed on the edges along shortest paths

assign_flows()

Elevation

Heights of nodes, grades of edges, travel times that depend on the grade

add_elevation(), apply_grade_speed()

Examples contains an executable notebook for every topic.


Installation

pip install iduedu

IduEdu supports Python 3.11–3.14 on Linux, macOS and Windows. Wheels contain the compiled extension, so pip needs no compiler; building from a source checkout requires a Rust toolchain (rustup). Optional extras: iduedu[io] writes and reads .urbangraph archives, iduedu[elevation] reads elevation rasters (rasterio). NetworkX is not installed with IduEdu and is needed only by the NetworkX helpers. Changes for code written for 2.x are listed in Upgrading to 3.0.


Quickstart

The builders download the territory from the Overpass API, or read it from a local OSM file. The second way is faster for large areas and does not depend on the public Overpass instance:

import iduedu
from iduedu import get_4326_boundary, get_intermodal_graph

# Vasilyevsky Island district, Saint Petersburg (OSM relation 1114252)
with iduedu.use_pbf(osm_id=1114252, region="northwestern-fed-district"):
    boundary = get_4326_boundary(osm_id=1114252)
    graph = get_intermodal_graph(territory=boundary, clip_by_territory=True)

Without the with block the same calls query the Overpass API. Routes and matrices then take node ids or GeoDataFrames of objects, which are matched to their nearest nodes:

nodes = graph.nodes_gdf.index
cost, route = graph.shortest_path(nodes[0], nodes[-1], weight="time_min")  # minutes, node ids
edges = graph.path_to_edges(route)  # the edges of the route with their geometry

matrix = graph.od_matrix(gdf_origins=buildings, gdf_destinations=schools, cutoff=30)

Network measures work on the same graph:

from iduedu import aggregate_objects, centrality

reach = centrality(graph, ["reach", "harmonic"], cutoffs=[10, 20], weight="time_min")
schools_within = aggregate_objects(graph, [10, 20], gdf_origins=buildings, gdf_objects=schools)

Configuration

Settings such as the Overpass endpoint, the response cache, a historical OSM date or the OSM tags kept on edges live in the global config object (see Configuration):

from iduedu import config

config.set_overpass_cache(cache_dir=".iduedu_cache", enabled=True)
config.configure_logging(level="INFO")

Contributing, contacts and citation

Issues and pull requests are welcome on GitHub; the workflow is described in CONTRIBUTING.md.

This research is financially supported by the Foundation for National Technology Initiative’s Projects Support as a part of the roadmap implementation for the development of the high-tech field of Artificial Intelligence for the period up to 2030 (agreement 70-2021-00187).

IduEdu is distributed under the BSD 3-Clause license (LICENSE.txt). To cite it, use the metadata in CITATION.cff (on GitHub, Cite this repository exports it as APA or BibTeX). Publications describing IduEdu will be listed here.