PostGIS raster value of a lat/lon point

You can transform the lat/lon point to raster CRS on the fly using ST_Transform(). Combined, the query looks like this:

ST_Value(your_raster, ST_Transform(ST_SetSRID(ST_MakePoint(lon,lat),4326),3035))

The function ST_value:

http://postgis.net/docs/RT_ST_Value.html

returns a raster value given a point in either x,y or lat,lon.


While ST_Value works, you still need to spatially join to the point as well:

SELECT ST_Value(your_raster.rast, ST_Transform(ST_SetSRID(ST_MakePoint(lon,lat),4326),3035))
FROM your_raster
WHERE ST_Intersects(your_raster.rast, ST_SetSRID(ST_MakePoint(lon,lat),4326),3035))

Or with a table:

SELECT ST_Value(your_raster.rast, ST_Transform(ST_SetSRID(ST_MakePoint(your_table.lon,your_table.lat),4326),3035))
FROM your_raster
JOIN your_table ON ST_Intersects(your_raster.rast, ST_SetSRID(ST_MakePoint(your_table.lon,your_table.lat),4326),3035))