ST_PixelAsCentroids
Name
ST_PixelAsCentroids — Returns the centroid (point geometry) for each pixel of a raster band along with the value, the X and the Y raster coordinates of each pixel. The point geometry is the centroid of the area represented by a pixel.
Synopsis
geometry
ST_PixelAsCentroids
(
raster
rast
, integer
band=1
, boolean
exclude_nodata_value=TRUE
)
;
Description
Returns the centroid (point geometry) for each pixel of a raster band along with the value, the X and the Y raster coordinates of each pixel. The point geometry is the centroid of the area represented by a pixel.
When exclude_nodata_value = TRUE, only those pixels whose values are not NODATA are returned as points. |
Availability: 2.1.0
Changed: 2.1.1 Changed behavior of exclude_nodata_value.
Examples
SELECT x, y, val, ST_AsText(geom) FROM (SELECT (ST_PixelAsCentroids(rast, 1)).* FROM dummy_rast WHERE rid = 2) foo; x | y | val | st_astext ---+---+-----+-------------------------------- 1 | 1 | 253 | POINT(3427927.775 5793243.975) 2 | 1 | 254 | POINT(3427927.825 5793243.975) 3 | 1 | 253 | POINT(3427927.875 5793243.975) 4 | 1 | 254 | POINT(3427927.925 5793243.975) 5 | 1 | 254 | POINT(3427927.975 5793243.975) 1 | 2 | 253 | POINT(3427927.775 5793243.925) 2 | 2 | 254 | POINT(3427927.825 5793243.925) 3 | 2 | 254 | POINT(3427927.875 5793243.925) 4 | 2 | 253 | POINT(3427927.925 5793243.925) 5 | 2 | 249 | POINT(3427927.975 5793243.925) 1 | 3 | 250 | POINT(3427927.775 5793243.875) 2 | 3 | 254 | POINT(3427927.825 5793243.875) 3 | 3 | 254 | POINT(3427927.875 5793243.875) 4 | 3 | 252 | POINT(3427927.925 5793243.875) 5 | 3 | 249 | POINT(3427927.975 5793243.875) 1 | 4 | 251 | POINT(3427927.775 5793243.825) 2 | 4 | 253 | POINT(3427927.825 5793243.825) 3 | 4 | 254 | POINT(3427927.875 5793243.825) 4 | 4 | 254 | POINT(3427927.925 5793243.825) 5 | 4 | 253 | POINT(3427927.975 5793243.825) 1 | 5 | 252 | POINT(3427927.775 5793243.775) 2 | 5 | 250 | POINT(3427927.825 5793243.775) 3 | 5 | 254 | POINT(3427927.875 5793243.775) 4 | 5 | 254 | POINT(3427927.925 5793243.775) 5 | 5 | 254 | POINT(3427927.975 5793243.775)