Converts pixels at a specified position of a raster into geometry objects, each represented by the centroid of the pixel.
Syntax
setof record ST_PixelAsCentroids(raster raster_obj,
integer band default 0,
integer pyramid default 0,
boolean exclude_nodata_value default true,
out integer rowsn,
out integer columnsn,
out integer bandsn,
out double value,
out geometry geom);Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
raster_obj | raster | — | The raster to query. |
band | integer | 0 | The band ID to query. Valid band IDs start from 0. |
pyramid | integer | 0 | The pyramid level to query. |
exclude_nodata_value | boolean | true | Specifies whether to exclude NoData pixels. |
rowsn | out integer | — | The row number of the pixel. |
columnsn | out integer | — | The column number of the pixel. |
bandsn | out integer | — | The band ID of the pixel. |
value | out double | — | The pixel value. |
geom | out geometry | — | The spatial extent of the pixel. |
Description
ST_PixelAsCentroids returns the same results as ST_PixelAsPoints when the ref_point parameter of ST_PixelAsPoints is set to CENTER.
Examples
WITH tmp AS (
SELECT (ST_PixelAsCentroids(rast, 1)).*
FROM rast_table
WHERE id = 10 )
SELECT rowsn, columnsn, bandsn, value, ST_AsEWKT(geom) FROM tmp WHERE value > 38.0;
----------------------------------------------------
100 | 100 | 0 | 43 | SRID=4326;POINT(-89.5 0.5)