Name

ST_PixelOfValue — Get the columnx, rowy coordinates of the pixel whose value equals the search value.

Synopsis

setof record ST_PixelOfValue( raster rast , integer nband , double precision[] search , boolean exclude_nodata_value=true );

setof record ST_PixelOfValue( raster rast , double precision[] search , boolean exclude_nodata_value=true );

setof record ST_PixelOfValue( raster rast , integer nband , double precision search , boolean exclude_nodata_value=true );

setof record ST_PixelOfValue( raster rast , double precision search , boolean exclude_nodata_value=true );

Description

Get the columnx, rowy coordinates of the pixel whose value equals the search value. If no band is specified, then band 1 is assumed.

Availability: 2.1.0

Examples

SELECT
	(pixels).*
FROM (
	SELECT
		ST_PixelOfValue(
			ST_SetValue(
				ST_SetValue(
					ST_SetValue(
						ST_SetValue(
							ST_SetValue(
								ST_AddBand(
									ST_MakeEmptyRaster(5, 5, -2, 2, 1, -1, 0, 0, 0),
									'8BUI'::text, 1, 0
								),
								1, 1, 0
							),
							2, 3, 0
						),
						3, 5, 0
					),
					4, 2, 0
				),
				5, 4, 255
			)
		, 1, ARRAY[1, 255]) AS pixels
) AS foo

 val | x | y 
-----+---+---
   1 | 1 | 2
   1 | 1 | 3
   1 | 1 | 4
   1 | 1 | 5
   1 | 2 | 1
   1 | 2 | 2
   1 | 2 | 4
   1 | 2 | 5
   1 | 3 | 1
   1 | 3 | 2
   1 | 3 | 3
   1 | 3 | 4
   1 | 4 | 1
   1 | 4 | 3
   1 | 4 | 4
   1 | 4 | 5
   1 | 5 | 1
   1 | 5 | 2
   1 | 5 | 3
 255 | 5 | 4
   1 | 5 | 5