跳转到主要内容

pgh_consistency

Pfafstetter consistency checks for PgHydro

pghydro : Pfafstetter consistency checks for PgHydro

Overview

ID Extension Package Version Category License Language
1606 pgh_consistency pghydro 6.6 GIS GPL-2.0 SQL
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
----d-- No No No Yes no no

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 6.6 18 17 16 15 14 pghydro plpgsql, postgis, pghydro
RPM PIGSTY 6.6 18 17 16 15 14 pghydro_$v postgis36_$v
DEB PIGSTY 6.6 18 17 16 15 14 postgresql-$v-pghydro postgresql-$v-postgis-3
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
el8.aarch64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
el9.x86_64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
el9.aarch64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
el10.x86_64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
el10.aarch64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
d12.x86_64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
d12.aarch64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
d13.x86_64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
d13.aarch64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
u22.x86_64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
u22.aarch64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
u24.x86_64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
u24.aarch64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
u26.x86_64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6
u26.aarch64 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 6.6 PIGSTY 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 via package name, for the active PG version
pig install pgh_consistency;		# install by extension name, for the current active PG version

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
pig install pgh_consistency -v 14;   # install for PG 14

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.