3

I would like to edit the metadata attributes of an tiff file. In particular the TIFFTAG attributes as described here.

In Python it's a piece of cake:

from osgeo import gdal  
ras = gdal.Open('test.tif', gdal.GA_Update)  
ras.SetMetadataItem('TIFFTAG_DATETIME', '2016:08:12 13:00:41')  
ras = None

Or you just use gdal_edit.py:

gdal_edit.py -mo TIFFTAG_DATETIME='2016:08:12 13:00:41' test.tif

Up until Version 0.5.27 rgdal seemed to have functions available for this (see here).

Does anyone know whether this can still be done?

3

It seems that currently R doesn't support gdal metadata tagging. The function you are looking for does no longer exist in rgdal and possibly have been deprecated. You may also notice that the setMetaData function was defined as a method of the GDALMajorObject-class (see here, p. 6). Currently however there are no methods associated with this class (see here, p. 10).

There is one option to write metadata to a GTiff using R. Yet, it is restricted to the file description, using rtiff::updateDescription().

Sets the TIFF description field (tag 270) for a TIFF file.

See here, p. 8. You need an updateDate() for tag 306.

Basically, there is no way to setMetaData in R, yet a work around may involve XML manipulations on the ...aux.xml file. You can write this file with the writeRaster(..., options = "PROFILE=GeoTIFF"). For my opinion it doesn't worth the trouble.

  • Thanks a lot for helping me out here! I'll try to get in touch with the package developers and see whether they have any suggestions. – John Truckenbrodt Aug 13 '16 at 19:47

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.