pgh_raster
PgHydro 栅格水文分析扩展
概览
| 扩展包名 | 版本 | 分类 | 许可证 | 语言 |
|---|---|---|---|---|
pghydro | 6.6 | GIS | GPL-2.0 | SQL |
| ID | 扩展名 | Bin | Lib | Load | Create | Trust | Reloc | 模式 |
|---|---|---|---|---|---|---|---|---|
| 1600 | pghydro | 否 | 否 | 否 | 是 | 否 | 否 | pghydro |
| 1601 | pgh_raster | 否 | 否 | 否 | 是 | 否 | 否 | pgh_raster |
| 1602 | pgh_hgm | 否 | 否 | 否 | 是 | 否 | 否 | pgh_hgm |
| 1603 | pgh_output | 否 | 否 | 否 | 是 | 否 | 否 | pgh_output |
| 1604 | pgh_output_en_au | 否 | 否 | 否 | 是 | 否 | 否 | pgh_output_en_au |
| 1605 | pgh_output_pt_br | 否 | 否 | 否 | 是 | 否 | 否 | pgh_output_pt_br |
| 1606 | pgh_consistency | 否 | 否 | 否 | 是 | 否 | 否 | pgh_consistency |
| 相关扩展 | plpgsql postgis postgis_raster pghydro |
|---|
版本
| 类型 | 仓库 | 版本 | PG 大版本 | 包名 | 依赖 |
|---|---|---|---|---|---|
| EXT | PIGSTY | 6.6 | 1817161514 | pghydro | plpgsql, postgis, postgis_raster, pghydro |
| RPM | PIGSTY | 6.6 | 1817161514 | pghydro_$v | postgis36_$v |
| DEB | PIGSTY | 6.6 | 1817161514 | postgresql-$v-pghydro | postgresql-$v-postgis-3 |
| OS / 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 |
构建
您可以使用 pig build 命令构建 pghydro 扩展的 RPM / DEB 包:
pig build pkg pghydro # 构建 RPM / DEB 包
安装
您可以直接安装 pghydro 扩展包的预置二进制包,首先确保 PGDG 和 PIGSTY 仓库已经添加并启用:
pig repo add pgsql -u # 添加仓库并更新缓存
使用 pig 或者是 apt/yum/dnf 安装扩展:
pig install pghydro; # 当前活跃 PG 版本安装
pig ext install -y pghydro -v 18 # PG 18
pig ext install -y pghydro -v 17 # PG 17
pig ext install -y pghydro -v 16 # PG 16
pig ext install -y pghydro -v 15 # PG 15
pig ext install -y pghydro -v 14 # PG 14
dnf install -y pghydro_18 # PG 18
dnf install -y pghydro_17 # PG 17
dnf install -y pghydro_16 # PG 16
dnf install -y pghydro_15 # PG 15
dnf install -y pghydro_14 # PG 14
apt install -y postgresql-18-pghydro # PG 18
apt install -y postgresql-17-pghydro # PG 17
apt install -y postgresql-16-pghydro # PG 16
apt install -y postgresql-15-pghydro # PG 15
apt install -y postgresql-14-pghydro # PG 14
创建扩展:
CREATE EXTENSION pgh_raster CASCADE; -- 依赖: plpgsql, postgis, postgis_raster, pghydro
用法
来源:PGHydro README,pgh_raster SQL
pgh_raster 为 PgHydro 增加基于栅格的水文产品。它保存 DEM、flow path、flow direction、flow accumulation 栅格,并提供上游/下游像元追踪、排水区分析、高程查询、高程剖面和栅格裁剪函数。
启用
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_raster;
CREATE EXTENSION pghydro;
CREATE EXTENSION pgh_raster;
栅格表
扩展创建 pgh_raster schema,其中包括:
| 表 | 用途 |
|---|---|
pghrt_elevation | 高程栅格数据 |
pghrt_flowpath | flow path 栅格数据 |
pghrt_flowdirection | flow direction 栅格数据 |
pghrt_flowaccumulation | flow accumulation 栅格数据 |
可以使用 raster2pgsql 等 PostGIS Raster 工具加载栅格产品,并确保 SRID 与切片方式匹配排水数据集。
分析函数
函数组包括下游和上游像元遍历、上游面积查询、下游排水点和排水区查询、高程像元值、高程剖面,以及栅格裁剪。
SELECT nspname, proname
FROM pg_proc p
JOIN pg_namespace n ON n.oid = p.pronamespace
WHERE nspname = 'pgh_raster'
ORDER BY proname;
注意事项
pgh_raster 同时依赖 pghydro 和 postgis_raster。派生水文地貌指标之前,应确保栅格对齐、SRID 和 nodata 处理与矢量排水图层一致。