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.
  • 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.1.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.1.0
File Size Uploaded Provenance
duckosm-0.1.0.tar.gz 317.8 kB With provenance Details

Built distribution (wheel)

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

Total release size: 580.9 kB

Release files / duckosm-0.1.0.tar.gz

Download URL duckosm-0.1.0.tar.gz
Size 317.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0e12978287a1658b2b5401b58d631f4540cee4d8a799b979c0ed4ce31e08713f
BLAKE2b-256 checksum
How to use checksums
fe3d3b86aff1e4972aeecda93d2f24d48e9fd61231f0b3dbe549bbd10d0f2023
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 3, 2026.

Transparency log

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

Download URL duckosm-0.1.0-py3-none-any.whl
Size 263.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87f7041f1b0cbf60a8e0c13c2d0fd4446246c1edc5425f72c581ced8b1a92f03
BLAKE2b-256 checksum
How to use checksums
a2f9aa093f459f9eae1dd158bda9f73e7868ad2c81d61ccf5ad59b2795d2e5c7
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 3, 2026.

Transparency log

Security for duckosm 0.1.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.1.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 3, 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