ST_NearestValue — 返回由 columnx 和 rowy 指定的给定波段像素,或由与栅格相同空间参考坐标系中表达的几何点指定的最近非-NODATA 值。
double precision ST_NearestValue(raster rast, integer bandnum, geometry pt, boolean exclude_nodata_value=true);
double precision ST_NearestValue(raster rast, geometry pt, boolean exclude_nodata_value=true);
double precision ST_NearestValue(raster rast, integer bandnum, integer columnx, integer rowy, boolean exclude_nodata_value=true);
double precision ST_NearestValue(raster rast, integer columnx, integer rowy, boolean exclude_nodata_value=true);
返回给定 columnx, rowy 像素中给定波段的最近非-NODATA 值,或在特定几何点处的最近非-NODATA 值。如果 columnx, rowy 像素或指定几何点处的像素为 NODATA,该函数将找到距离 columnx, rowy 像素或几何点最近的且其值不是 NODATA 的像素。
波段编号从 1 开始,如果未指定,则假定 bandnum 为 1。如果 exclude_nodata_value 设置为 false,则所有像素(包括 nodata 像素)都将被视为相交并返回值。如果未传入 exclude_nodata_value,则从栅格的元数据中读取。
可用性: 2.1.0
|
|
|
ST_NearestValue 是 ST_Value 的直接替代品。 |
-- pixel 2x2 has value
SELECT
ST_Value(rast, 2, 2) AS value,
ST_NearestValue(rast, 2, 2) AS nearestvalue
FROM (
SELECT
ST_SetValue(
ST_SetValue(
ST_SetValue(
ST_SetValue(
ST_SetValue(
ST_AddBand(
ST_MakeEmptyRaster(5, 5, -2, 2, 1, -1, 0, 0, 0),
'8BUI'::text, 1, 0
),
1, 1, 0.
),
2, 3, 0.
),
3, 5, 0.
),
4, 2, 0.
),
5, 4, 0.
) AS rast
) AS foo
value | nearestvalue
-------+--------------
1 | 1
-- pixel 2x3 is NODATA
SELECT
ST_Value(rast, 2, 3) AS value,
ST_NearestValue(rast, 2, 3) AS nearestvalue
FROM (
SELECT
ST_SetValue(
ST_SetValue(
ST_SetValue(
ST_SetValue(
ST_SetValue(
ST_AddBand(
ST_MakeEmptyRaster(5, 5, -2, 2, 1, -1, 0, 0, 0),
'8BUI'::text, 1, 0
),
1, 1, 0.
),
2, 3, 0.
),
3, 5, 0.
),
4, 2, 0.
),
5, 4, 0.
) AS rast
) AS foo
value | nearestvalue
-------+--------------
| 1