Tuesday, 13 August 2019

PostGIS raster value of a lat/lon point


I have a tiff raster in my PostGIS 2.0 database. I want to get the value of the raster at a specified lat/lon point.



I have:



  • postgresql-9.1

  • postgis-2.0-svn with raster support

  • a raster imported into PostGIS its SRID is 3035



Answer



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))

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...