Command line and Python¶
For a script, a server or Python code, use duckOSM. It uses the same Rust engine as the page and gives the same tables.
duckOSM 0.7.0 and newer have this engine in the duckosm wheel, for Linux, macOS and Windows.
Build from the command line¶
-
Install duckOSM:
pip install duckosm -
Get an
.osm.pbffile from Geofabrik. -
Build the networks. Repeat
--modesfor each network:duckosm build --pbf monaco.osm.pbf --output monaco.duckdb --modes driving --modes walking --modes cycling
The result is one DuckDB file (The tables).
Read the tables in Python¶
import duckdb
con = duckdb.connect("monaco.duckdb", read_only=True)
con.execute("SELECT highway, count(*) FROM driving.edges GROUP BY highway").fetchall()