名称

ST_PixelAsPolygons — 返回与每个像素的值、X 和 Y 栅格坐标一起限定栅格波段的每个像素的多边形几何。

概要

setof record ST_PixelAsPolygons(raster rast, integer band=1, boolean exclude_nodata_value=TRUE);

描述

返回与每个像素的值(双精度)、X 和 Y 栅格坐标(整数)一起限定栅格波段的每个像素的多边形几何。

返回记录格式:geom geometryval 双精度,x 整数,y 整数。

[Note]

exclude_nodata_value = TRUE 时,仅将值不是 NODATA 的像素作为点返回。

[Note]

ST_PixelAsPolygons 为每个像素返回一个多边形几何。这不同于 ST_DumpAsPolygons,其中每个几何表示一个或多个具有相同像素值像素。

可用性:2.0.0

增强:2.1.0 添加了 exclude_nodata_value 可选参数。

更改:2.1.1 更改了 exclude_nodata_value 的行为。

示例

-- get raster pixel polygon
SELECT (gv).x, (gv).y, (gv).val, ST_AsText((gv).geom) geom
FROM (SELECT ST_PixelAsPolygons(
                 ST_SetValue(ST_SetValue(ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 0.001, -0.001, 0.001, 0.001, 4269),
                                                    '8BUI'::text, 1, 0),
                                         2, 2, 10),
                             1, 1, NULL)
) gv
) foo;

 x | y | val |                geom
---+---+-----------------------------------------------------------------------------
 1 | 1 |     | POLYGON((0 0,0.001 0.001,0.002 0,0.001 -0.001,0 0))
 1 | 2 |   1 | POLYGON((0.001 -0.001,0.002 0,0.003 -0.001,0.002 -0.002,0.001 -0.001))
 2 | 1 |   1 | POLYGON((0.001 0.001,0.002 0.002,0.003 0.001,0.002 0,0.001 0.001))
 2 | 2 |  10 | POLYGON((0.002 0,0.003 0.001,0.004 0,0.003 -0.001,0.002 0))
  

另请参见

ST_DumpAsPolygonsST_PixelAsPolygonST_PixelAsPointST_PixelAsPointsST_PixelAsCentroidST_PixelAsCentroidsST_AsText