ST_PixelAsPolygons — 返回包围栅格带的每个像素的多边形几何图形以及每个像素的值、X 和 Y 栅格坐标。
setof record ST_PixelAsPolygons(
raster rast, integer band=1, boolean exclude_nodata_value=TRUE)
;
返回包围栅格带的每个像素的多边形几何图形以及每个像素的值(双精度)、X 和 Y 栅格坐标(整数)。
返回记录格式:geom
geometry,val
双精度,x
整数,y
整数。
当 |
ST_PixelAsPolygons 为每个像素返回一个多边形几何图形。 这与 ST_DumpAsPolygons 不同,其中每个几何图形代表一个或多个具有相同像素值的像素。 |
可用性: 2.0.0
增强:2.1.0 添加了 except_nodata_value 可选参数。
更改:2.1.1 更改了 except_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))