The two previous sections returned information about the raster and geometries representing the raster data. This section will show you how to query your raster dataset for values.
To get the value of a specific cell, you use ST_Value, which is shown as follows:
cursor.execute("select ST_Value(rast,4,3) from bigi;")cursor.fetchall()
The previous code passes the raster, the column, and row to ST_Value. Optionally, you can pass false if you want don't want to return any data values. The result of the previous query is shown as follows:
[(51.0,)]
The output is the value at the given cell.
If you want to search for all pixels with a given value, you can use ST_PixelOfValue, as follows:
cursor.execute("select ST_PixelOfValue(rast,1,50) ...