raster_h3
raster_h3 · Aggregate geospatial rasters into H3 cells with native PostgreSQL functions.
Overview
PostgreSQL · 13, 14, 15, 16, 17, 18
Usage
Sources:
raster_h3 converts GeoTIFF and cloud-optimized rasters into H3 cell aggregates. Version 0.7.0 provides a native Rust library using PostgreSQL’s function-manager ABI, without PGRX. It supports PostgreSQL 13–18 on little-endian 64-bit systems; the library must match the server major version.
Enable and aggregate
Install the matching library and extension files, then enable the extension as a superuser:
The continuous function returns summary statistics; the categorical function returns class counts, proportions, diversity and a JSON-text histogram. Both also return a cell index, resolution and WKB geometry. Each call computes one resolution, from 0 through 15. Optional arguments include source_crs, nodata and bbox; the bounding box uses longitude/latitude limits.
Privileges and helpers
Raster paths are opened by the database server, including supported HTTP(S) and S3 URLs. The two aggregation functions revoke EXECUTE from PUBLIC and grant it to pg_read_server_files. That role also permits broader server-file access, so grant it only to appropriate operators. Scalar helpers do not need raster-file access.
The scalar API includes h3_to_string, string_to_h3, h3_to_lat, h3_to_lng, h3_get_resolution, h3_is_valid, h3_to_wkb and h3_cell_to_parent. PostGIS is optional for consuming the returned WKB with ST_GeomFromWKB; it is not an installation dependency.
Limits and maintenance
No shared preload or server restart is required by the extension. Existing installations from 0.4.0 onward have SQL upgrade paths via ALTER EXTENSION raster_h3 UPDATE. The PostgreSQL interface does not expose the project’s Parquet/PMTiles writers, band selection or quantile options; use the separate upstream interfaces for those operations. Statistics weight pixel contributions, not ground area. Check the source CRS and any transformation warnings when interpreting results.