Search Shortcut cmd + k | ctrl + k
duck_dggs

DuckDB extension for discrete global grid systems (DGGS) powered by DGGRID v8, Built against DuckDB v1.5.1.

Maintainer(s): am2222

Installing and Loading

INSTALL duck_dggs FROM community;
LOAD duck_dggs;

Example

INSTALL duck_dggs FROM community;
LOAD duck_dggs;

-- Geographic point → cell ID at resolution 5 (default ISEA4H grid)
SELECT geo_to_seqnum('POINT(0.0 0.0)'::GEOMETRY, 5);
-- → 2380

-- Cell ID → cell centre point
SELECT seqnum_to_geo(2380, 5);
-- → POINT (-0.9020481125846749 -1.2067949803565235e-09)

-- Cell ID → cell boundary polygon (requires the spatial extension)
LOAD spatial;
SELECT seqnum_to_boundary(2380, 5);
-- → POLYGON ((0.095 0.667, -0.922 1.336, -1.916 0.669, -1.916 -0.669, -0.922 -1.336, 0.095 -0.667, 0.095 0.667))

-- Use a custom grid (ISEA3H — aperture 3 hexagons)
SELECT geo_to_seqnum('POINT(0.0 0.0)'::GEOMETRY, 5,
    dggs_params('ISEA', 3, 'HEXAGON', 0.0, 58.28252559, 11.25));
-- → 572

About duck_dggs

duck_dggs transforms geographic coordinates (as GEOMETRY POINT) to and from DGGS cell identifiers across multiple coordinate reference frames, powered by DGGRID v8.

All transform functions accept a GEOMETRY POINT (x = longitude°, y = latitude°) and a resolution integer. Every function has a second overload that accepts an explicit dggs_params struct for full control over the grid configuration.

Grid configuration

All functions use ISEA4H by default (ISEA projection, aperture 4, hexagon topology). Pass a dggs_params struct as the last argument to use a different grid:

dggs_params(projection, aperture, topology, azimuth_deg, pole_lat_deg, pole_lon_deg)

Common presets:

Grid Call
ISEA4H (default) dggs_params('ISEA', 4, 'HEXAGON', 0.0, 58.28252559, 11.25)
ISEA3H dggs_params('ISEA', 3, 'HEXAGON', 0.0, 58.28252559, 11.25)
ISEA4T (triangles) dggs_params('ISEA', 4, 'TRIANGLE', 0.0, 58.28252559, 11.25)
ISEA4D (diamonds) dggs_params('ISEA', 4, 'DIAMOND', 0.0, 58.28252559, 11.25)
FULLER4H dggs_params('FULLER', 4, 'HEXAGON', 0.0, 58.28252559, 11.25)

Utility functions:

  • duck_dggs_version() — extension version string
  • dggs_params(projection, aperture, topology, azimuth_deg, pole_lat_deg, pole_lon_deg) — build a grid configuration

Transform functions (each has a res and optional params overload):

  • From geo: geo_to_seqnum, geo_to_geo, geo_to_plane, geo_to_projtri, geo_to_q2dd, geo_to_q2di
  • From seqnum: seqnum_to_geo, seqnum_to_boundary, seqnum_to_seqnum, seqnum_to_plane, seqnum_to_projtri, seqnum_to_q2dd, seqnum_to_q2di - From Q2DI: q2di_to_seqnum, q2di_to_geo, q2di_to_plane, q2di_to_projtri, q2di_to_q2dd, q2di_to_q2di
  • From Q2DD: q2dd_to_seqnum, q2dd_to_geo, q2dd_to_plane, q2dd_to_projtri, q2dd_to_q2dd, q2dd_to_q2di
  • From projtri: projtri_to_seqnum, projtri_to_geo, projtri_to_plane, projtri_to_projtri, projtri_to_q2dd, projtri_to_q2di

Added Functions

function_name function_type description comment examples
dggs_params scalar NULL NULL  
duck_dggs_version scalar NULL NULL  
geo_to_geo scalar NULL NULL  
geo_to_plane scalar NULL NULL  
geo_to_projtri scalar NULL NULL  
geo_to_q2dd scalar NULL NULL  
geo_to_q2di scalar NULL NULL  
geo_to_seqnum scalar NULL NULL  
projtri_to_geo scalar NULL NULL  
projtri_to_plane scalar NULL NULL  
projtri_to_projtri scalar NULL NULL  
projtri_to_q2dd scalar NULL NULL  
projtri_to_q2di scalar NULL NULL  
projtri_to_seqnum scalar NULL NULL  
q2dd_to_geo scalar NULL NULL  
q2dd_to_plane scalar NULL NULL  
q2dd_to_projtri scalar NULL NULL  
q2dd_to_q2dd scalar NULL NULL  
q2dd_to_q2di scalar NULL NULL  
q2dd_to_seqnum scalar NULL NULL  
q2di_to_geo scalar NULL NULL  
q2di_to_plane scalar NULL NULL  
q2di_to_projtri scalar NULL NULL  
q2di_to_q2dd scalar NULL NULL  
q2di_to_q2di scalar NULL NULL  
q2di_to_seqnum scalar NULL NULL  
seqnum_to_boundary scalar NULL NULL  
seqnum_to_geo scalar NULL NULL  
seqnum_to_plane scalar NULL NULL  
seqnum_to_projtri scalar NULL NULL  
seqnum_to_q2dd scalar NULL NULL  
seqnum_to_q2di scalar NULL NULL  
seqnum_to_seqnum scalar NULL NULL  

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

This extension does not add any settings.