I need to get longitude, latitude and altitude info for each pixel in GeoTiff image. I have installed GDAL in my system. Since I am new to GDAL I don't know how to proceed further.
How can I get the information that I need using GDAL and C++?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
I'm not sure what you mean by "for each pixel". look at the raster API tutorial: http://gdal.org/gdal_tutorial.html. specifically look at the section "Getting Dataset Information".
do you want to get the information that gets dumped by the gdalinfo tool? that is easy. the gdalinfo tool source code comes-with the source download. just get it and look at it. very easy to understand.
Now I see the "altitude" part. Duh.
The raster (pixels) are numbers which are the altitudes. if you know the pixel row/col, it is relatively easy to get the lat/lon/alt. look at the source for gdallocationinfo. it will show you how to take coordinates and look up the pixel. You'd do the same thing, but you don't need to convert from coordinates to pixel since you're starting with pixel coordinate. then you want to convert the pixel to coordinates in some SRS. look at gdaltransform for that.
Also the tutorials. The raster API tutorial (http://gdal.org/gdal_tutorial.html) will show you how to open the tif and read the altitude. Then you use the inverse of the geo transform to convert the pixel row/col to the coordinates in the TIF's SRS. The tutorial will also show you how to get the SRS for the tif.
The TIF SRS may not be geodetic coordinates, or not in the datum you wish. If that is the case, the OGR tutorial (http://gdal.org/gdal_tutorial.html) will show you how to convert coordinates from the TIF's SRS to the one you want (e.g. WGS84).
I cannot stress enough that the tutorials and source code for the GDAL raster utilities are your friend. All that you're asking to do has been implemented in those utilities, which are simple and very well written.
Because you speak of altitude, I assume your GeoTIFF is an image of a Digital Elevation Model, where each pixel value is the elevation at that point.
gdallocationinfo is a command line tool you could use.
The source code of that is here: https://svn.osgeo.org/gdal/trunk/gdal/apps/gdallocationinfo.cpp . You can probably lift something from there if you want pure C++. Otherwise, call
gdallocationinfo in a shell loop.