Search Shortcut cmd + k | ctrl + k

Hex9 hierarchical hexagonal DGGS — point encoding, layer binning, cell geometry as WKB, labels, k-rings, Hamiltonian-curve ordering, and grid enumeration

Maintainer(s): MrBenGriffin

Installing and Loading

INSTALL hex9 FROM community;
LOAD hex9;

Example

SELECT h9_encode(-3.19, 55.95) AS cell;
SELECT h9_label(h9_encode(-3.19, 55.95), 8) AS label;
SELECT h9_cell(h9_encode(-3.19, 55.95), 8) AS wkb;  -- pair with spatial's ST_GeomFromWKB
SELECT h9_curve_index(h9_curve(h9_encode(-3.19, 55.95))) AS locality;

About hex9

Hex9 is an equal-area hierarchical hexagonal DGGS (discrete global grid system), backed by libhex9 — the same core as its PostGIS extension. Cells are 16-byte UUIDs; every full address is reversible, and layer-scoped bins derived from it serve as join keys. Vectorized scalar functions (encode/decode/bin, lineage, k-rings, labels, Hamiltonian-curve locality ordering with HUGEINT indexes) plus table functions (h9_grid, h9_curve_cells, h9_owned_cells). Geometry is emitted as WKB, consumed directly by the spatial extension. Since libhex9 2.1.0 the encode chain is deterministic: the same lon/lat yields the bit-identical uuid on every platform, enforced by in-repo universality pin tests.

Added Functions

function_name function_type description comment examples
h9_bin scalar NULL NULL  
h9_cell scalar NULL NULL  
h9_cell_ancestor scalar NULL NULL  
h9_cell_children scalar NULL NULL  
h9_cell_parent scalar NULL NULL  
h9_common_ancestor scalar NULL NULL  
h9_curve scalar NULL NULL  
h9_curve_bin scalar NULL NULL  
h9_curve_cells table NULL NULL  
h9_curve_decode scalar NULL NULL  
h9_curve_from_label scalar NULL NULL  
h9_curve_index scalar NULL NULL  
h9_curve_label scalar NULL NULL  
h9_curve_layer scalar NULL NULL  
h9_curve_pack scalar NULL NULL  
h9_decode scalar NULL NULL  
h9_decode_wkb scalar NULL NULL  
h9_encode scalar NULL NULL  
h9_grid table NULL NULL  
h9_id_from_int scalar NULL NULL  
h9_id_int scalar NULL NULL  
h9_is_curve scalar NULL NULL  
h9_kdisk scalar NULL NULL  
h9_kring scalar NULL NULL  
h9_label scalar NULL NULL  
h9_label_centroid scalar NULL NULL  
h9_label_key scalar NULL NULL  
h9_lmax scalar NULL NULL  
h9_neighbors scalar NULL NULL  
h9_owned_cells table NULL NULL  
h9_parse_label scalar NULL NULL  
h9_version 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.