Skip to content

pgh_raster

Raster hydrology extension for PgHydro

pghydro · Raster hydrology extension for PgHydro

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
1601pgh_rasterpghydro6.6GISGPL-2.0SQL
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
----d--NoNoNoYesnono

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY6.619 18 17 16 15pghydroplpgsql, postgis, postgis_raster, pghydro
RPMPIGSTY6.619 18 17 16 15pghydro_$vpostgis37_$v
DEBPIGSTY6.619 18 17 16 15postgresql-$v-pghydropostgresql-$v-postgis-3
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
el8.aarch64N/APIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
el9.x86_64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
el9.aarch64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
el10.x86_64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
el10.aarch64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
d12.x86_64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
d12.aarch64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
d13.x86_64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
d13.aarch64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
u22.x86_64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
u22.aarch64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
u24.x86_64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
u24.aarch64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
u26.x86_64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6
u26.aarch64PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6PIGSTY 6.6

Source

pig build pkg pghydro;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pghydro;		# install by package name
pig install pgh_raster;		# install by extension name

pig install pgh_raster -v 19;   # install for PG 19
pig install pgh_raster -v 18;   # install for PG 18
pig install pgh_raster -v 17;   # install for PG 17
pig install pgh_raster -v 16;   # install for PG 16
pig install pgh_raster -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION pgh_raster CASCADE; -- requires plpgsql, postgis, postgis_raster, pghydro

Usage

Sources: PGHydro README, pgh_raster SQL

pgh_raster adds raster-based hydrological products to PgHydro. It stores DEM, flow-path, flow-direction, and flow-accumulation rasters, then exposes functions for upstream/downstream pixel tracing, drainage-area analysis, elevation lookup, elevation profiles, and raster clipping.

Enable

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_raster;
CREATE EXTENSION pghydro;
CREATE EXTENSION pgh_raster;

Raster Tables

The extension creates the pgh_raster schema with tables such as:

TablePurpose
pghrt_elevationElevation raster data
pghrt_flowpathFlow-path raster data
pghrt_flowdirectionFlow-direction raster data
pghrt_flowaccumulationFlow-accumulation raster data

Load raster products with PostGIS Raster tooling such as raster2pgsql, using the SRID and tiling scheme that matches the drainage dataset.

Analysis Functions

Function groups include downstream and upstream pixel traversal, upstream area lookup, downstream drainage point and area lookup, elevation pixel values, elevation profiles, and raster clipping.

SELECT nspname, proname
FROM pg_proc p
JOIN pg_namespace n ON n.oid = p.pronamespace
WHERE nspname = 'pgh_raster'
ORDER BY proname;

Notes

pgh_raster depends on both pghydro and postgis_raster. Keep raster alignment, SRID, and nodata handling consistent with the vector drainage layers before deriving hydrogeomorphological metrics.

Table reader