1

I am currently using GDAL from Python to read and transform coordinates and that works well. I would now like to be able to read some of the none geographic tags, for example, TIFFTAG_DATETIME using GDAL. I have searched the net but have been unable to find any examples. Can anyone help?

1

You can install the GDAL library from OSGEO here: http://www.osgeo.org/ , there are also nice Windows binaries located at here thanks to Tamas Szekeres. Just make sure you install the right version for the version of Python your running.

In your Python code you can import the library like so:

from osgeo import gdal

Then in your code body, you can get a reference to you raster, say, by iterating over a folder of tif's like below...

...
for raster in glob.glob(rootdir + "*.tif"):
...

Then invoke GDAL to open the raster and get a 'handle' to the data source like:

ds = gdal.Open(raster, 0) 

Use "GetMetadataItem" method to pick out the metadata item you're interested in like so:

print ds.GetMetadataItem("TIFFTAG_DATETIME")

You can review other metadata tags here: http://www.gdal.org/gdal_datamodel.html

Close the raster dataset

ds = None
| improve this answer | |
  • 1
    Can you provide some context/guidance for the code that you have supplied as an answer, please? Code only answers tend to attract flags and downvotes. – PolyGeo Jul 14 '16 at 22:06

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.