Skip to content

pgh_consistency

Pfafstetter consistency checks for PgHydro

pghydro · Pfafstetter consistency checks for PgHydro

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
1606pgh_consistencypghydro6.6GISGPL-2.0SQL
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
----d--NoNoNoYesnono

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY6.619 18 17 16 15pghydroplpgsql, postgis, 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_consistency;		# install by extension name

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

Create this extension with:

CREATE EXTENSION pgh_consistency CASCADE; -- requires plpgsql, postgis, pghydro

Usage

Sources: PGHydro README, pgh_consistency SQL

pgh_consistency is a PgHydro companion extension for checking and cleaning hydrographic network data. It creates the pgh_consistency schema with quality-control tables and functions for drainage-line and drainage-area geometry, topology, and Pfafstetter consistency checks.

Enable

Install it after PostGIS and the core pghydro extension:

CREATE EXTENSION postgis;
CREATE EXTENSION pghydro;
CREATE EXTENSION pgh_consistency;

Inspect Check Tables

The extension stores findings in tables named after the issue being detected:

SELECT tablename
FROM pg_tables
WHERE schemaname = 'pgh_consistency'
ORDER BY tablename;

Examples include pghft_drainagelineisdisconnected, pghft_drainagelineisnotvalid, pghft_drainageareaisnotvalid, pghft_drainageareaoverlapdrainagearea, pghft_pointvalencevalue2, and pghft_pointdivergent.

Main Workflows

Use the functions in pgh_consistency to prepare and validate the drainage network before running analytical PgHydro routines. The SQL objects include helpers to split drainage lines at multipoints, snap drainage lines to a grid, remove repeated points, create drainage-line vertex intersections, break drainage lines, and detect invalid, non-simple, disconnected, overlapping, looping, or misclassified drainage features.

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

Notes

The extension assumes PgHydro’s base drainage tables are already populated. Run consistency checks before exporting or calculating higher-level hydrological products so invalid geometries and broken network links are visible early.

Table reader