Skip to main content

duckOSM

OpenStreetMap → a routable road network in one DuckDB file,
with edge IDs that survive every rebuild, clip and export.

PyPI CI Docs Python 3.10+ License MIT

Documentation · Your first network · Guides · Database schema · Query the database


Why duckOSM

Most OSM-to-network tools number their edges 0, 1, 2, …, so the numbers change whenever you rebuild, cut out an area or export, and every table keyed on them has to be matched again. duckOSM's edge_id is a content hash of three ids that OpenStreetMap already gives the road segment: the OSM way it comes from (osm_id) and the OSM nodes where it starts and ends (source, target):

edge_id = hash(osm_id, source, target)

The order of source and target is the direction, so the two directions of a two-way street get different ids. None of the three is a number duckOSM makes up, so the id stays the same across rebuilds, clips and exports (details).

Quick start

pip install "duckosm[routing]"

curl -LO https://download.geofabrik.de/europe/monaco-latest.osm.pbf
duckosm build --pbf monaco-latest.osm.pbf --output monaco.duckdb --modes driving
import duckdb
from duckosm import route

con = duckdb.connect("monaco.duckdb", read_only=True)
q = "SELECT min(edge_id) FROM driving.edges WHERE name = ?"
a = con.execute(q, ["Boulevard du Larvotto"]).fetchone()[0]
b = con.execute(q, ["Avenue Princesse Grace"]).fetchone()[0]

r = route(con, a, b)                     # fastest path; weight="length" for distance
r["time_s"], r["length_m"], r["edges"]   # ~114 s, ~1.5 km, the ordered edge_ids

What you get

  • A driving, a walking and a cycling network in one file, one schema each, split at the same junctions so a road has the same edge_id in every mode. OSM access tags are respected: private roads are kept for the map but never routed (details).
  • The graph of legal turns (edge_graph), with OSM turn restrictions, for routing in SQL, Python or networkx.
  • Base-map layers (features.*: water, land use, buildings, POIs) in the same file.
  • Maps in one offline HTML page: duckosm viz draws the network and the base map from the database; duckosm route-map is a route planner (drive, walk, cycle, walk + drive) where you drag a start and an end and get turn-by-turn directions (try it). The pages are drawn by mapstyle.
  • The drawing order of the roads: duckosm levels stores which road is painted over which (casing and fill numbers) in the file (how).
  • Any area: a GeoJSON boundary, a place name, a box or an H3 cell; duckosm boundary finds an area's border by name, and duckosm extract cuts a city out of a country build in seconds.
  • Your own fixes for OSM errors, applied on every build (how).

Exports

Format Command How it's verified
SUMO duckosm sumo SUMO's own netconvert assembles the network
MATSim duckosm matsim, matsim-lanes validated against MATSim's official DTD and XSD schemas
GMNS duckosm gmns follows the GMNS table spec
GeoPackage / shapefile duckosm export-gis duckosm gis-debug reads it back through GDAL and diffs every edge_id
networkx duckosm export-graph unit tests

Experimental: OpenDRIVE, Lanelet2, railML, lane-level routing, GMNS meso/micro, intermodal routing, elevation, admin boundaries, base-map layers. See the documentation.

For AI agents

  • To use duckOSM: the agent skill skills/duckosm/SKILL.md (also a Claude Code plugin: /plugin marketplace add Khoshkhah/duckOSM), and the whole documentation as one text file: llms-full.txt (llms.txt is its index).
  • duckosm info DB --json says what a database holds; way, route-lanes and gis-debug also take --json.
  • To change duckOSM: the rules are in AGENTS.md.

License

MIT. duckOSM is built on DuckDB and its spatial extension; it is an independent project, not affiliated with or endorsed by the DuckDB Foundation.

Metadata

Release files for duckosm 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for duckosm 0.2.0
File Size Uploaded Provenance
duckosm-0.2.0.tar.gz 323.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for duckosm 0.2.0
File Interpreter ABI Platform
duckosm-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 589.9 kB

Release files / duckosm-0.2.0.tar.gz

Download URL duckosm-0.2.0.tar.gz
Size 323.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2de76815d8066ba8a06962eb1928f9d333d1341440688e1347b86144857507b0
BLAKE2b-256 checksum
How to use checksums
3d8531da119b1f14423b7f6b40fca5cca4ef56843ca6f16823f89960cf2ff1df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release files / duckosm-0.2.0-py3-none-any.whl

Download URL duckosm-0.2.0-py3-none-any.whl
Size 266.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9cd4756ae7dd0f96fb100335ca5e4ae3ef2553e6969ad196bc170ce3f9d8b332
BLAKE2b-256 checksum
How to use checksums
9761c58542af31e69ded267814baf7dccc4c1a2028c0c37cd7b26208584c43c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Security for duckosm 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for duckosm-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page