Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted
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;
share|improve this answer
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
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
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 posting your answer, you agree to the privacy policy and terms of service.

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