I have a table in postgresql that contains ID, row number, column number, pixel value and centroid of the pixel in WGS84 lat-lon system(4326). How could I extract the pixel value by giving a point in 4326 reference system?

SELECT pixel_value FROM raster_table
WHERE ST_Intersects(ST_SetSRID(ST_Point(xcoord,ycoord), 4326),rast)=TRUE;

Then according to your new comments the SQL-command could be

SELECT pixel_value FROM your_table_with_pixels
WHERE ST_Intersects(ST_SetSRID(ST_Point(xcoord,ycoord), 4326),ST_Buffer(geom, resolution_of_raster_cell))=TRUE;
  • Thank you Vladimir, but maybe my question was not clear enough. I'm not working on postgis raster. This is just a set of pixels of a raster file with row number, column number, pixel values and pixel centroid in 4326. – f.ashouri Oct 30 '12 at 14:28
  • 1
    The pixels have to have coordinates, otherwise it is impossible to extract values. Where are the coordinates of pixels stored? – Vladimir Oct 30 '12 at 14:34
  • the coordinates of centroid of pixels are available. – f.ashouri Oct 30 '12 at 15:20
  • 1
    What is their representation? As geometry PostGIS data type? WKT? WKB? – Vladimir Oct 30 '12 at 15:24
  • yes, geometry type WKT – f.ashouri Oct 30 '12 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.