Fanning Software Consulting

Georeferenced TIFF Files

QUESTION: I have received a TIFF file from a colleague. How can I determine whether this file contains georeferenced information inside it from within IDL? That is to say, how can I determine if this is a GeoTIFF file as compared to a regular TIFF file?

ANSWER: The easiest way to do this is to open the file with the GEOTIFF keyword set to a previously undefined variable:

   IDL> Undefine, tiffInfo
   IDL> image = Read_TIFF('myfile.tif', GEOTIFF=tiffInfo)

If the tiffInfo variable is undefined, this is not a GeoTIFF image. If it is defined, then it will be defined as a structure, each field of which is a GeoTIFF tag.

   IDL> IF N_Elements(tiffInfo) EQ 0 THEN Print, 'This is not a GeoTiff image' ELSE $
            Help, tiffInfo, /Structure

Note the use of the Undefine procedure to be sure your variable in undefined prior to passing it into the GEOTIFF keyword.

Web Coyote's Guide to IDL Programming