h3_postgis
pg_h3 : H3 PostGIS integration
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 1531 | h3_postgis | pg_h3 | 4.5.0 |
GIS | Apache-2.0 | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-r | No | Yes | No | Yes | yes | no |
| Relationships | |
|---|---|
| Requires | h3 postgis postgis_raster |
| See Also | postgis qdgc pg_geohash pgrouting q3c pg_polyline pg_eviltransform earthdistance mobilitydb |
| Siblings | h3 |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 4.5.0 |
18 17 16 15 14 | pg_h3 |
h3, postgis, postgis_raster |
| RPM | PIGSTY | 4.5.0 |
18 17 16 15 14 | h3-pg_$v |
- |
| DEB | PIGSTY | 4.5.0 |
18 17 16 15 14 | postgresql-$v-h3 |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| el8.aarch64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| el9.x86_64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| el9.aarch64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| el10.x86_64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| el10.aarch64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| d12.x86_64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| d12.aarch64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| d13.x86_64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| d13.aarch64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| u22.x86_64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| u22.aarch64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| u24.x86_64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| u24.aarch64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| u26.x86_64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
| u26.aarch64 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 | PIGSTY 4.5.0 |
Source
github.com/postgis/h3-pg
h3-pg-4.5.0.tar.gz h3-4.5.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
h3_postgis bridges H3 cells with PostGIS geometry, geography, and raster. It requires h3, postgis, and postgis_raster, including for geometry-only use. Input geometries must use SRID 4326 with longitude, latitude coordinates; the functions do not reproject inputs.
Convert Points and Cells
Transform other coordinate systems to SRID 4326 with PostGIS before calling the H3 functions. Setting an SRID label alone does not transform coordinates.
Core API
| Task | Functions |
|---|---|
| Point to cell | h3_latlng_to_cell(geometry, integer), h3_latlng_to_cell(geography, integer) |
| Cell center | h3_cell_to_geometry, h3_cell_to_geography |
| Cell boundary | h3_cell_to_boundary_geometry, h3_cell_to_boundary_geography |
| Polygon coverage | h3_polygon_to_cells, h3_cells_to_multi_polygon_geometry, h3_cells_to_multi_polygon_geography |
| Continuous raster summaries | h3_raster_summary, h3_raster_summary_stats_agg |
| Categorical raster summaries | h3_raster_class_summary, h3_raster_class_summary_item_agg |
The geometry-to-resolution @ operator also maps a location to an H3 cell. Validate polygon inputs with ST_IsValid(); repairs through ST_MakeValid() can change topology and produce geometry collections, so retain and review polygonal components before coverage calculations. Invalid polygons have undefined behavior.
Summarize Raster Data
The default summary chooses a method; explicit clip, centroid, and subpixel variants let you control how raster pixels are assigned to cells. Review the choice against raster resolution and the requested H3 resolution.
Upgrade and Boundaries
The base extension update performs affected btree rebuilds and distance-dependent refreshes, so plan its maintenance window before updating the companion. Version 4.5.0 fixes restricted-search-path maintenance on PostgreSQL 17+, expression-index dump/restore, and several geometry and polygonization errors. Both extension versions should match. Install the matching 4.5.0 package files before updating either extension.
h3.extend_antimeridian should normally remain false for planar overlays. Both extensions are relocatable; ensure the schemas containing H3 and PostGIS objects are visible when issuing unqualified SQL. Neither extension requires shared preloading.