[GIS] Extract Longitude and Latitude from Geotiff (ASTER 30m DEM)

geotiff-tifflatitude longitudematlab-mapping-toolboxqgis

my problem is apparently quite simple, but I cannot really find an easy answer: in QGIS I've created a raster layer by merging different GeoTiff images from the ASTER 30m DEM dataset.

The merging is ok: by moving the cursor I can see that the coordinates make sense and so the elevation.

What I'd like now is to extract the longitude and latitude informations from each pixel (generating a matrix the size of the layer with Lat values and one with Lon values), but I really don't know how to do it.

I also tried to import the image in MATLAB using the geotiffread function, but I cannot extract such information…

Thanks to all!

Best Answer

I suggest not to create such a matrix, which could be quite inefficient, but if you really need this, you create an ascii file with Long, lat, and value as columns, (which you can import in Matlab.)

gdal_translate -of XYZ input.tif output.asc

gdal is also available from qgis as a plugin (with a GUI), but you can use it directly as a command line.

Note that you can find your coordinates directly based on the row and column number. The easiest case is a starting from a matrix that is already in long/lat, in other words a regular grid in Lat/long coordinate system.

so you need to extract the upper left corner coordiantes, and the lat/long can be computed based on the index of you element

lat = upperLeftLat - Ysize*row

long = upperLeftLong + XSize*column

If you are not in this ideal case, you need to account for the rotation of the matrix and, potentially, the projection. But this can also be done "on the fly" without creating a new matrix (although if you need to reproject your data, it is better to do it first).

Related Question