Skip to content
DuckDB community extension

valhalla_routing

DuckDB extension for routing and travel time calculations using Valhalla routing engine

01 / SETUP

Install and load

Run these commands in a Haybarn SQL session. The extension is available from the community repository.

Haybarn 2.0.0 · SQL
INSTALL valhalla_routing FROM community;
LOAD valhalla_routing FROM community;

Try it in a temporary SQL session with valhalla_routing already loaded. Queries run in this tab; examples using files or services need their own setup.

Using upstream DuckDB? Follow the maintainer’s installation instructions.

02 / QUERY

Usage example

SQL
-- Load extensions
INSTALL httpfs; LOAD httpfs;
INSTALL spatial; LOAD spatial;

-- Download and build tiles (Pure SQL!)
SELECT valhalla_build_tiles(
    'https://download.geofabrik.de/europe/monaco-latest.osm.pbf',
    './monaco_tiles'
);

-- Load tiles
SET valhalla_tiles = './monaco_tiles';

-- Calculate route
SELECT
    round(r.distance_km, 1) as km,
    round(r.duration_minutes, 1) as minutes,
    ST_NPoints(r.geometry) as waypoints
FROM (
    SELECT valhalla_route(
        ST_Point(7.4275, 43.7397),  -- Casino Monte-Carlo
        ST_Point(7.4254, 43.7308),  -- Oceanographic Museum
        'auto'
    ) as r
);

Provided by midwork-finds-jobs. Not yet verified on Haybarn 2.0.0.

Sample data & setup

About this extension

Point-to-point routing with distance, duration, and geometry using the Valhalla routing engine.

Project overview from the community descriptor.

Documentation and resources

Project and build details
Repository
midwork-finds-jobs/duckdb-valhalla-routing
License
MIT
Maintainers
onnimonni
Written in
C++
Build source
7d4bf9ad8f3f
Build definition
Community descriptor