pgh3
pgh3 · Expose Uber H3 hierarchical geospatial indexing functions for PostGIS geometries
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100144 | pgh3 | pgh3 | 0.3.0 | GIS | Apache-2.0 | C |
PostgreSQL · 10, 11, 12, 13
| Relationships | |
|---|---|
| Requires | postgis |
Usage
Sources:
pgh3 0.3.0 is an archived binding between PostGIS geometries and an older Uber H3 C API. It represents H3 indexes as text and provides point indexing, cell geometry, hierarchy, neighborhood, polygon filling, compaction, and average-size helpers.
Point and Cell Workflow
Install PostGIS first. Coordinates are interpreted as longitude in X and latitude in Y, in degrees; the wrapper does not transform or validate a geometry’s SRID.
Transform source geometries to longitude/latitude before calling the extension. Returned PostGIS geometries are constructed without preserving an SRID, so set the expected SRID explicitly where downstream spatial operations require it.
Main Function Groups
h3_geo_to_h3index(point, integer)and itsgeometryoverload create an index.h3_h3index_to_geo(text)andh3_h3index_to_geoboundary(text)return cell center and boundary geometry.h3_kring(text, integer),h3_to_parent(text, integer), andh3_to_children(text, integer)navigate neighbors and hierarchy.h3_compact(text[])andh3_uncompact(text[], integer)change hierarchical representation.h3_hexagon_area_km2(integer),h3_hexagon_area_m2(integer),h3_edge_length_km(integer), andh3_edge_length_m(integer)return average size measures.
Polygon Filling and Memory
Estimate cardinality before materializing a fill, especially at fine resolutions.
h3_polyfill supports Polygon and MultiPolygon geometries and omits holes. It preallocates the estimated output. pgh3.polyfill_mem limits that allocation and defaults to PostgreSQL’s approximately 1 GB MaxAllocSize; increasing it can create very large backend allocations. Prefer lower resolution or split input with PostGIS before raising the limit.
Compatibility Boundary
The extension targets pre-H3-v4 function names and is tightly coupled to the H3 library ABI used at build time. Its repository is archived and does not establish support beyond the historical PostgreSQL range. Build against an explicitly matched H3 release, verify known cell IDs and geometry orientation, and prefer a maintained H3 extension for new production systems.