I'm writing a specialized tool in C to work with DEM data (typically GeoTIFF files, but one of the reasons I'm using libgdal is to leverage its ability to read multiple formats).

I'm able to open a GeoTIFF file and get at some of the metadata, but how do I get at the elevation data (e.g., given a pixel location, get the height) programmatically?

Perhaps I need to index into the raw raster data myself.


You are looking for GDALRasterBand::RasterIO. For efficiency, if you are indexing multiple points, you will want to read data in blocks then index into the resulting array

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.