You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A DuckDB extension for discrete global grid systems (DGGS) powered by DGGRID v8.
Transforms geographic coordinates to and from ISEA grid cell identifiers across multiple reference frames.
Building
git submodule update --init --recursive
GEN=ninja make
For faster incremental builds:
brew install ccache ninja
The main binaries produced:
./build/release/duckdb — DuckDB shell with the extension loaded
-- lon, lat → cell ID at resolution 5 (default ISEA4H grid)SELECT geo_to_seqnum(0.0, 0.0, 5);
-- → 2380-- cell ID → cell centreSELECT seqnum_to_geo(2380, 5);
-- → {'lon_deg': 0.0, 'lat_deg': 0.0}-- unpack struct fieldsSELECTr.lon_deg, r.lat_degFROM (SELECT seqnum_to_geo(2380, 5) AS r);
-- use a custom grid (ISEA3H — aperture 3 hexagons)SELECT geo_to_seqnum(0.0, 0.0, 5,
dggs_params('ISEA', 3, 'HEXAGON', 0.0, 58.28252559, 11.25));
Grid configuration
All functions use ISEA4H by default (ISEA projection, aperture 4, hexagon topology). Pass a dggs_params struct as the last argument to any transform function to use a different grid.
-- Store params in a column, use across many rows
WITH p AS (
SELECT dggs_params('ISEA', 3, 'HEXAGON', 0.0, 58.28252559, 11.25) AS grid
)
SELECT geo_to_seqnum(lon, lat, 5, p.grid)
FROM my_points, p;
Functions
Every transform function has two overloads:
fn(…, res) — uses the default ISEA4H grid
fn(…, res, params) — uses the supplied dggs_params struct