h3_postgis
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_h3 | 4.2.3 | GIS | Apache-2.0 | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 1530 | h3 | No | Yes | No | Yes | No | Yes | - |
| 1531 | h3_postgis | No | Yes | No | Yes | No | Yes | - |
| Related | h3 postgis postgis_raster mobilitydb postgis_topology postgis_sfcgal postgis_tiger_geocoder address_standardizer address_standardizer_data_us pgrouting pointcloud |
|---|
pgdg missing el8.x86.pg17 and el8.x86.pg18
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 4.2.3 | 1817161514 | pg_h3 | h3, postgis, postgis_raster |
| RPM | PGDG | 4.2.3 | 1817161514 | h3-pg_$v | - |
| DEB | PGDG | 4.2.3 | 1817161514 | postgresql-$v-h3 | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG MISS | PGDG MISS | PGDG 4.1.3 | PGDG 4.1.3 | PGDG 4.1.3 |
| el8.aarch64 | PGDG 4.2.3 | PGDG 4.1.3 | PGDG 4.1.3 | PGDG 4.1.3 | PGDG 4.1.3 |
| el9.x86_64 | PGDG 4.2.3 | PGDG 4.1.3 | PGDG 4.1.3 | PGDG 4.1.3 | PGDG 4.1.3 |
| el9.aarch64 | PGDG 4.2.3 | PGDG 4.1.3 | PGDG 4.1.3 | PGDG 4.1.3 | PGDG 4.1.3 |
| el10.x86_64 | PGDG 4.2.3 | PGDG 4.2.2 | PGDG 4.2.2 | PGDG 4.2.2 | PGDG 4.2.2 |
| el10.aarch64 | PGDG 4.2.3 | PGDG 4.2.2 | PGDG 4.2.2 | PGDG 4.2.2 | PGDG 4.2.2 |
| d12.x86_64 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 |
| d12.aarch64 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 |
| d13.x86_64 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 |
| d13.aarch64 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 |
| u22.x86_64 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 |
| u22.aarch64 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 |
| u24.x86_64 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 |
| u24.aarch64 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 | PGDG 4.2.3 |
Install
You can install pg_h3 directly. First, make sure the PGDG repository is added and enabled:
pig repo add pgdg -u # Add PGDG repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pg_h3; # Install for current active PG version
pig ext install -y pg_h3 -v 18 # PG 18
pig ext install -y pg_h3 -v 17 # PG 17
pig ext install -y pg_h3 -v 16 # PG 16
pig ext install -y pg_h3 -v 15 # PG 15
pig ext install -y pg_h3 -v 14 # PG 14
dnf install -y h3-pg_18 # PG 18
dnf install -y h3-pg_17 # PG 17
dnf install -y h3-pg_16 # PG 16
dnf install -y h3-pg_15 # PG 15
dnf install -y h3-pg_14 # PG 14
apt install -y postgresql-18-h3 # PG 18
apt install -y postgresql-17-h3 # PG 17
apt install -y postgresql-16-h3 # PG 16
apt install -y postgresql-15-h3 # PG 15
apt install -y postgresql-14-h3 # PG 14
Create Extension:
CREATE EXTENSION h3_postgis CASCADE; -- requires: h3, postgis, postgis_raster
Usage
h3_postgis is a bridge extension that integrates the H3 hexagonal hierarchical spatial index with PostGIS. It enables conversion between H3 indexes and PostGIS geometry types.
CREATE EXTENSION h3_postgis CASCADE;
This extension requires both h3 and postgis to be installed. It provides functions to convert between H3 cell indexes and PostGIS geometries, enabling spatial queries that combine H3’s hexagonal grid system with PostGIS’s spatial capabilities.
Key Functions
-- Convert a PostGIS point to an H3 cell index
SELECT h3_latlng_to_cell(ST_MakePoint(-73.985, 40.748)::point, 9);
-- Get the boundary of an H3 cell as a PostGIS geometry
SELECT h3_cell_to_boundary_geometry('892a1008003ffff'::h3index);
-- Convert H3 cells to PostGIS polygons for visualization
SELECT h3_cell_to_geometry('892a1008003ffff'::h3index);
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.