Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I'm reading some GeoTIFF files into my app using libgeotiff. After the model of the listgeo program that comes with libgeotiff, I want to extract the extents (corners) of the GeoTIFF so I can position it.

I only really want to deal with coords in WGS84 and UTM (ultimately, I'll convert WGS84 to UTM). However, I don't know which bit of the GeoTIFF info tells me what I want to know about the 'corner' coords. Obviously, I can use the magnitude of the numbers to guess if the resulting coords are lats and longs, but surely there must be an official way?

Something like (pseudo-code):

If (geotifftag == UTM || geotifftag == WGS84)
    // Proceed
    Msg("Unrecognised data format")
End If

Could anybody help me out with what the GeoTIFF tags actually tell me?

share|improve this question

marked as duplicate by BradHards, Fezter, MappaGnosis, Curlew, Simbamangu Nov 23 '13 at 16:18

This question was marked as an exact duplicate of an existing question.

Looks like you asked the same question (in a slightly more advanced way) again. – BradHards Nov 23 '13 at 3:29

The easiest way to do this is through the GDAL API - see the tutorial - your question then comes down to:

if( poDataset->GetProjectionRef()  != NULL )
    printf( "Projection is `%s'\n", poDataset->GetProjectionRef() );

if( poDataset->GetGeoTransform( adfGeoTransform ) == CE_None )
    printf( "Origin = (%.6f,%.6f)\n",
            adfGeoTransform[0], adfGeoTransform[3] );

    printf( "Pixel Size = (%.6f,%.6f)\n",
            adfGeoTransform[1], adfGeoTransform[5] );

and there is no difficulty reprojecting the corners to WGS84 if it is in a different projection.

share|improve this answer
GDAL is a comparatively heavyweight alternative. I tried it, but I'm left with the same problem. I'm not sure what 'projection' my corners are using. "There is no difficult reprojecting the corners" - well, no difficulty if youknow how to do that and/or can penetrate the feeble GDAL documentation (I can't!) – Kyudos May 22 '13 at 1:08

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