h3_postgis

h3_postgis

pg_h3 : H3 PostGIS integration

Overview

ID Extension Package Version Category License Language
1531
h3_postgis
pg_h3
4.2.3
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
mobilitydb
postgis_topology
postgis_sfcgal
postgis_tiger_geocoder
address_standardizer
address_standardizer_data_us
pgrouting
pointcloud
Siblings
h3

pgdg missing el8.x86.pg17 and el8.x86.pg18

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PGDG
4.2.3
18
17
16
15
14
pg_h3 h3, postgis, postgis_raster
RPM
PGDG
4.2.3
18
17
16
15
14
h3-pg_$v -
DEB
PGDG
4.2.3
18
17
16
15
14
postgresql-$v-h3 -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
MISS
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

Source

Install

Make sure PGDG repo available:

pig repo add pgdg -u    # add pgdg repo and update cache

Install this extension with pig:

pig install pg_h3;		# install via package name, for the active PG version
pig install h3_postgis;		# install by extension name, for the current active PG version

pig install h3_postgis -v 18;   # install for PG 18
pig install h3_postgis -v 17;   # install for PG 17
pig install h3_postgis -v 16;   # install for PG 16
pig install h3_postgis -v 15;   # install for PG 15
pig install h3_postgis -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION h3_postgis CASCADE; -- requires h3, postgis, postgis_raster

Usage

h3_postgis: PostGIS integration for H3

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);
Last updated on