This function is used to convert the pixels at a specified position of a raster into geometric objects, each of which is represented by the point in the center of the geometric object.
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 | Description |
---|---|
raster_obj | The raster that you want to query. |
band | The IDs of the bands that you want to query. Valid band IDs start from 0. |
pyramid | The ID of the pyramid level that you want to query. |
exclude_nodata_value | Specifies whether to exclude NoData pixels. |
rowsn | The number of the row in which the pixel resides. |
columnsn | The number of the column in which the pixel resides. |
bandsn | The ID of the band to which the pixel belongs. |
value | The value of the pixel. |
geom | The spatial extent of the pixel. |
Description
This function converts the pixels at a specified position of a raster into geometric objects, each of which is represented by the point in the center of the geometric object. You can obtain the same results for the specified pixels if you set the ref_point parameter of the ST_PixelAsPoints function 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)