0

I am trying to find elevation data of a particular coordinate(lat/long) from a raster file(EPSG:4326) using QGIS C++ APIs. I am able to render a raster file on QgsMapCanvas, which means GDAL is working in my application. Which APIs should be used to extract elevation value using lat/long value. Any lead will be valuable even if it is in PyQGIS.

menes
  • 1,421
  • 2
  • 7
  • 24
Puneet Kumar
  • 95
  • 11
  • 1
    GDAL has functions to convert between raster and world coordinates, using the GeoTransform associated with the Tiff file. You should ba able to convert from world coordinates to raster coordinates and sample the raster at that point. – wingnut May 12 '21 at 07:05
  • QGIS https://opensourceoptions.com/blog/pyqgis-query-raster-values/ With GDAL, try https://gis.stackexchange.com/questions/221292/retrieve-pixel-value-with-geographic-coordinate-as-input-with-gdal You may also look at gdallocationinfo https://github.com/OSGeo/gdal/blob/master/gdal/swig/python/gdal-utils/osgeo_utils/samples/gdallocationinfo.py (Python) or https://github.com/OSGeo/gdal/blob/fec15b146f8a750c23c5e765cac12ed5fc9c2b85/gdal/apps/gdallocationinfo.cpp (C++) – ThomasG77 May 12 '21 at 14:14

0 Answers0