ST_Slope — 返回高程栅格带的坡度(默认以度为单位)。 对于分析地形很有用。
raster ST_Slope(raster rast, integer nband=1, text pixeltype=32BF, text units=DEGREES, double precision scale=1.0, boolean interpolate_nodata=FALSE);
raster ST_Slope(raster rast, integer nband, raster customextent, text pixeltype=32BF, text units=DEGREES, double precision scale=1.0, boolean interpolate_nodata=FALSE);
返回高程栅格带的坡度(默认以度为单位)。 利用地图代数并将斜率方程应用于相邻像素。
units表示斜率的单位。 可能的值为:弧度、度(默认)、百分比。
比例(scale)是垂直单位与水平单位的比率。 对于英尺:LatLon 使用scale=370400,对于米:LatLon 使用scale=111120。
如果 interpolate_nodata 为 TRUE,则在计算表面坡度之前,将使用 ST_InvDistWeight4ma对输入栅格中的 NODATA 像素值进行插值。
|
|
|
有关坡度、坡向和山体阴影的更多信息,请参阅 ESRI - 山体阴影的工作原理和 ERDAS 现场指南 - 坡度图像。 |
可用性: 2.0.0
增强:2.1.0 使用 ST_MapAlgebra() 并添加可选units、scale、interpolate_nodata 函数参数
更改:2.1.0 在之前的版本中,返回值以弧度为单位。 现在,返回值默认为度数
WITH foo AS (
SELECT ST_SetValues(
ST_AddBand(ST_MakeEmptyRaster(5, 5, 0, 0, 1, -1, 0, 0, 0), 1, '32BF', 0, -9999),
1, 1, 1, ARRAY[
[1, 1, 1, 1, 1],
[1, 2, 2, 2, 1],
[1, 2, 3, 2, 1],
[1, 2, 2, 2, 1],
[1, 1, 1, 1, 1]
]::double precision[][]
) AS rast
)
SELECT
ST_DumpValues(ST_Slope(rast, 1, '32BF'))
FROM foo
st_dumpvalues
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------
(1,"{{10.0249881744385,21.5681285858154,26.5650520324707,21.5681285858154,10.0249881744385},{21.5681285858154,35.2643890380859,36.8698959350586,35.2643890380859,21.5681285858154},
{26.5650520324707,36.8698959350586,0,36.8698959350586,26.5650520324707},{21.5681285858154,35.2643890380859,36.8698959350586,35.2643890380859,21.5681285858154},{10.0249881744385,21.
5681285858154,26.5650520324707,21.5681285858154,10.0249881744385}}")
(1 row)
覆盖范围图块的完整示例。 此查询仅适用于 PostgreSQL 9.1 或更高版本。
WITH foo AS (
SELECT ST_Tile(
ST_SetValues(
ST_AddBand(
ST_MakeEmptyRaster(6, 6, 0, 0, 1, -1, 0, 0, 0),
1, '32BF', 0, -9999
),
1, 1, 1, ARRAY[
[1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 2, 1],
[1, 2, 2, 3, 3, 1],
[1, 1, 3, 2, 1, 1],
[1, 2, 2, 1, 2, 1],
[1, 1, 1, 1, 1, 1]
]::double precision[]
),
2, 2
) AS rast
)
SELECT
t1.rast,
ST_Slope(ST_Union(t2.rast), 1, t1.rast)
FROM foo t1
CROSS JOIN foo t2
WHERE ST_Intersects(t1.rast, t2.rast)
GROUP BY t1.rast;