ST_PixelAsPoints — Returns a point geometry for each pixel of a raster band along with the value, the X and the Y raster coordinates of each pixel. The coordinates of the point geometry are of the pixel's upper-left corner.
setof record ST_PixelAsPoints(raster rast, integer band=1, boolean exclude_nodata_value=TRUE);
Returns a point geometry for each pixel of a raster band along with the value, the X and the Y raster coordinates of each pixel. The coordinates of the point geometry are of the pixel's upper-left corner.
Return record format: geom geometry, val double precision, x integer, y integers.
|
|
|
When |
Availability: 2.1.0
Changed: 2.1.1 Changed behavior of exclude_nodata_value.
This example returns point features together with a derived marker size that a client can use for value-scaled point rendering.
SELECT
x,
y,
val,
round((val / 32.0)::numeric, 2) AS marker_scale,geom AS geom
FROM (
SELECT (ST_PixelAsPoints(rast, 1)).*
FROM dummy_rast
WHERE rid = 2
) AS foo
ORDER BY y, x;
x | y | val | marker_scale | geom ---+---+-----+--------------+------------------------------ 1 | 1 | 253 | 7.91 | POINT(3427927.75 5793244) 2 | 1 | 254 | 7.94 | POINT(3427927.8 5793244) 3 | 1 | 253 | 7.91 | POINT(3427927.85 5793244) 4 | 1 | 254 | 7.94 | POINT(3427927.9 5793244) 5 | 1 | 254 | 7.94 | POINT(3427927.95 5793244) 1 | 2 | 253 | 7.91 | POINT(3427927.75 5793243.95) 2 | 2 | 254 | 7.94 | POINT(3427927.8 5793243.95) 3 | 2 | 254 | 7.94 | POINT(3427927.85 5793243.95) 4 | 2 | 253 | 7.91 | POINT(3427927.9 5793243.95) 5 | 2 | 249 | 7.78 | POINT(3427927.95 5793243.95) 1 | 3 | 250 | 7.81 | POINT(3427927.75 5793243.9) 2 | 3 | 254 | 7.94 | POINT(3427927.8 5793243.9) 3 | 3 | 254 | 7.94 | POINT(3427927.85 5793243.9) 4 | 3 | 252 | 7.88 | POINT(3427927.9 5793243.9) 5 | 3 | 249 | 7.78 | POINT(3427927.95 5793243.9) 1 | 4 | 251 | 7.84 | POINT(3427927.75 5793243.85) 2 | 4 | 253 | 7.91 | POINT(3427927.8 5793243.85) 3 | 4 | 254 | 7.94 | POINT(3427927.85 5793243.85) 4 | 4 | 254 | 7.94 | POINT(3427927.9 5793243.85) 5 | 4 | 253 | 7.91 | POINT(3427927.95 5793243.85) 1 | 5 | 252 | 7.88 | POINT(3427927.75 5793243.8) 2 | 5 | 250 | 7.81 | POINT(3427927.8 5793243.8) 3 | 5 | 254 | 7.94 | POINT(3427927.85 5793243.8) 4 | 5 | 254 | 7.94 | POINT(3427927.9 5793243.8) 5 | 5 | 254 | 7.94 | POINT(3427927.95 5793243.8)