Skip to content

Notebook manual

The chapters of duckOSM's Python SDK are in one place: the notebook manual. Each chapter is one Jupyter notebook on Monaco, with the outputs of its last run. This page lists the chapters, with a button to run each one in Colab and a link to download it. Each notebook installs duckOSM when it is not installed.

The core

The core: get a network, look inside it, draw it, join your data by edge_id, fix the OSM data and export it. Start with chapter 1.

Chapter Module What you learn Run
1. Get and build an area core The parts of a build, seven ways to choose an area, the modes, your own PBF file, the build options and config=, how you save a network Open in Colab
Download the notebook
2. Look inside the file core The schemas and tables of the file, the columns with their meaning, the edges and nodes as DataFrames, SQL on the file, your own DuckDB connection Open in Colab
Download the notebook
3. Draw maps core net.map as a live map, a link, a picture or a plot; the layers; the dashboard; net.plot with the colors of the modes Open in Colab
Download the notebook
4. Join your data by edge_id core Join traffic counts to the edges by edge_id, color the map by them, and keep the join after a rebuild Open in Colab
Download the notebook
5. Fix the OSM data once duckosm.fixes Change one OSM tag in the fixes file, build again, and see the fix in the route, the map and six outputs Open in Colab
Download the notebook
6. Exports core SUMO, GMNS, MATSim, OpenDRIVE, GeoPackage, the QuackOSM table and PMTiles, each with a check Open in Colab
Download the notebook

The modules

Each module is for one group of users (the modules). duckosm.routing has two chapters: the basics (7) and the Route object with its analyses (8).

Chapter Module What you learn Run
7. Routing duckosm.routing Routes between roads, points and place names and across modes; turn-by-turn steps; networkx and rustworkx graphs Open in Colab
Download the notebook
8. Advanced routing duckosm.routing The Route object, many routes, the k best routes, a travel time matrix, isochrones and accessibility Open in Colab
Download the notebook
9. Street network analysis duckosm.analysis The numbers of OSMnx in two views, junctions, street directions, connected parts, nearest roads, clip, random points, heights and grades Open in Colab
Download the notebook
10. OSM data for GIS duckosm.gis OSM features as GeoDataFrames, the network as OSM XML, the administrative areas, GIS files Open in Colab
Download the notebook
11. Mobility data duckosm.mobility Map matching of GPS traces onto edge_id, sensors on the edges, counts per edge and hour, the old edge ids after a rebuild Open in Colab
Download the notebook
12. Traffic simulation duckosm.sim The SUMO network read with sumolib, a short SUMO run and its counts joined back by edge_id; MATSim links and lanes Open in Colab
Download the notebook
13. Transport planning duckosm.planning The GMNS tables and their checks, the meso and micro networks, path4gmns and AequilibraE Open in Colab
Download the notebook
14. HD maps duckosm.hdmap The lanes as a CommonRoad map and a Lanelet2 map, the lane graph and a route from lane to lane, OpenDRIVE Open in Colab
Download the notebook
15. Graph machine learning duckosm.ml The junction graph and the turn graph for networkx, rustworkx and PyTorch Geometric; a graph neural network that learns the speed limits; a GMNS graph (links, junctions, turns) that fills the missing lanes tags Open in Colab
Download the notebook

Run a notebook on your computer

pip install "duckosm[all]" jupyterlab
jupyter lab

The notebooks write their files (data/, out/) in the folder of the notebook. Each one needs a connection to the internet: it downloads the Monaco extract from Geofabrik.

The CI workflow runs the notebooks on each change of the code or of a notebook. A failed cell fails the workflow.