Function index

Every public name is imported from the package itself, from iduedu import .... The tables link to the reference page of each function; the topic pages explain how they work.

Building graphs

Data sources, Streets: drive, walk and bike, Public transport from OpenStreetMap, Public transport from GTFS, Intermodal graphs

get_drive_graph

Build a drivable UrbanGraph from OpenStreetMap within a given territory.

get_walk_graph

Build a pedestrian UrbanGraph from OpenStreetMap within a given territory.

get_bike_graph

Build a cycling UrbanGraph from OpenStreetMap within a given territory.

get_street_graph

Build one street network for walking, driving and cycling, with every street stored once.

mode_graph

Take the graph of one mode from a street graph of get_street_graph().

get_public_transport_graph

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

route_edges

Travel edges of one route in the order of travel.

route_stops

Stop nodes of one route in the order the route calls at them.

routes_in_area

Routes of the graph with a travel edge or a stop in an area.

get_gtfs_public_transport_graph

Build a static public-transport UrbanGraph from a local GTFS feed.

get_intermodal_graph

Build an intermodal (PT+walking) UrbanGraph for a territory.

join_pt_walk_graph

Join public-transport and pedestrian UrbanGraph objects into an intermodal graph.

merge_gtfs_feeds

Combine several GTFS feeds into one that the graph builder can consume.

deduplicate_across_feeds

Count once what several merged feeds publish twice.

TransportSpec

Configuration of a public-transport mode or service used to estimate travel time on graph edges.

TransportRegistry

Registry of public-transport specifications for modes and service variants.

get_4326_boundary

Normalize a territory boundary to a single EPSG:4326 Polygon.

use_pbf

Temporarily read OSM data from a local file, or from a territory downloaded from Geofabrik.

download_osm_pbf

OSM file for a territory, cut out of a Geofabrik extract: a drop-in replacement for Overpass downloads.

download_geofabrik_region

Download the Geofabrik extract region (an id from geofabrik_regions()).

find_geofabrik_region

Id of the smallest Geofabrik extract that fully covers territory (EPSG:4326 for shapely input).

geofabrik_regions

Geofabrik extracts as a GeoDataFrame in EPSG:4326.

PbfSource

A local OpenStreetMap .osm.pbf file answering the queries IduEdu otherwise sends to Overpass.

split_by_polygons

Write one compact, referentially complete <name>.osm.pbf per polygon from a regional extract.

snapshot_time

Return the moment an OSM file reflects, from its header, as an aware UTC datetime.

The graph model

The UrbanGraph model, Graph operations

UrbanGraph

Tabular representation of an urban transport graph.

read_urban_graph

Read an UrbanGraph from an .urbangraph archive.

write_urban_graph

Write an UrbanGraph to an .urbangraph archive.

validate_graph

Validate all node, edge, topology and CRS contracts of an UrbanGraph.

subgraph_by_nodes

Return an induced UrbanGraph subgraph for the provided node ids.

clip_urban_graph

Clip graph nodes by geometry and keep only edges with retained endpoints.

join_urban_graphs

Join two compatible UrbanGraph objects by concatenating node and edge tables.

relabel_urban_graph

Relabel node ids and update edge endpoints.

to_directed

Return a directed copy of UrbanGraph using a boolean edge direction column.

to_undirected

Return an undirected copy of UrbanGraph.

simplify_multiedges

Collapse a multigraph UrbanGraph into a simple graph.

simplify_graph

Merge chains of edges through nodes of degree two into single edges.

consolidate_intersections

Merge groups of nearby nodes, such as the several nodes of one junction of dual carriageways, into one.

unique_segments

Return the straight segments the edge geometries are made of, each physical segment once.

connected_components

Return connected components of an undirected UrbanGraph.

weakly_connected_components

Return weakly connected components.

strongly_connected_components

Return strongly connected components.

keep_largest_connected_component

Keep only the largest component of an UrbanGraph.

nearest_nodes

Return the nearest graph node id for each input geometry.

nearest_edges

Return the nearest graph edge for each input geometry, with the distance and the position along it.

project_objects2urban_graph

Prepare graph changes that connect objects to their nearest edges.

apply_urban_graph_changes

Apply prepared changes to an UrbanGraph.

UrbanGraphChanges

Set of table changes that can be applied to an UrbanGraph.

GraphEdits

Edits of a graph given by lines in any CRS, resolved by resolve_graph_edits().

coordinate_node_ids

Stable int64 node ids packed from the coordinates of points.

resolve_graph_edits

Bind geometric edits to the current graph.

Routing

Shortest paths and matrices, Routes between two points

single_source_dijkstra

Search from one node; return distances, paths, or both from one traversal.

multi_source_dijkstra

Search from the nearest member of one combined source set.

multi_source_dijkstra_nearest_source

Return nearest source_node and dist columns for each reachable node.

dijkstra_parallel

Run independent searches, sharing work for sources mapped to the same node.

single_source_dijkstra_path

Return one shortest node route, or [] when unreachable or beyond cutoff.

od_matrix

Compute OD distances, node routes, or both with one search per unique source.

iter_od_matrix

Yield OD results in origin-row blocks, using the same options as od_matrix.

path_to_edges

Convert an ordered node path to ordered graph edges.

ShortestPathResult

Distances and paths from the same Dijkstra searches.

shortest_path

Return the cost and the node route of one shortest path from source_node to target_node.

alternative_paths

Return up to k distinct routes from source_node to target_node by the penalty method.

k_shortest_paths

Return up to k shortest loopless paths from source_node to target_node (Yen's algorithm).

Network analysis

Network statistics, Objects around origins, Centrality, Flow assignment, Elevation

graph_stats

Measures of size, density, shape and connectivity of a street network.

local_stats

Network measures around every node, within a travel cost along the network.

edge_stats

Edge counts, lengths and speeds for every value of an edge column.

transport_stats

Stops, routes and stop spacing of every public-transport mode of a graph.

streets_per_node

Number of streets that meet at every node.

route_directness

Ratio of the shortest network distance to the straight distance between origins and destinations.

nearest_objects

Find the k nearest objects of every origin along the network.

aggregate_objects

Count objects and sum their values within a travel cost of every origin.

diversity

Diversity of object categories within a travel cost of every origin.

centrality

Centralities of the nodes of a graph within travel-cost thresholds.

edge_betweenness

Betweenness of the edges of a graph: how many shortest paths within a threshold run along each edge.

assign_flows

Assign flows from sources to attractive nodes along shortest paths and sum them on the edges.

add_elevation

Add node heights and edge grades to a graph.

apply_grade_speed

Rescale the travel times of a graph with elevation by a speed model that depends on the grade.

NetworkX

Optional; install networkx separately (see Graph operations).

urban_graph2nx_graph

Convert an UrbanGraph to a NetworkX graph.

nx_graph2urban_graph

Convert a NetworkX graph to an UrbanGraph.

graph2gdf

Convert a NetworkX graph to GeoDataFrames for nodes and/or edges.

gdf2graph

Convert a GeoDataFrame of LineStrings into a directed graph (nx.DiGraph).

keep_largest_nx_component

Keep only the largest connected component of a NetworkX graph.

clip_nx_graph

Clip a NetworkX graph by a polygon and return the induced subgraph.

read_gml

Read a GML file into a NetworkX graph and cast edge geometry from WKT strings to shapely.

write_gml

Write a NetworkX graph to GML, coercing node coordinates to plain floats.

reproject_graph

Reproject node coordinates (x, y) and edge geometries to a new CRS (in place).

Settings

iduedu.config holds the Overpass endpoint, the cache, the OSM source and logging; see Configuration.