Using gdal, where (and how) do I store raster metadata so that it can be viewed in ArcGIS (or similar)?

Gdal datasources and raster band objects have the methods SetMetadata and GetMetadata. These seem to work fine to store the data, and I can get/set the data using Python. However I can't seem to find or view the metadata entries in ArcGIS. An example of what I tried to do is below:

import gdal
import numpy as np

# Some data
fname = 'metadata_test.tif'
data = np.ones([100,100], dtype=int)
lats = np.arange(0, 10, 10.0/100)
lons = np.arange(0, 10, 10.0/100)

# Create data source
driver = gdal.GetDriverByName('GTiff')
ds = driver.Create(fname, len(lons), len(lats), 1, gdal.GDT_Byte)

# Set metadata in datasource
ds.SetMetadata({'description':'test description'}) 

# Set sample data
out_band = ds.GetRasterBand(1)

del ds

If you load the test data, you will see that the metadata has indeed been set:

ds = gdal.Open(fname)
Out[8]: {'description': 'test description'}

However, I can't find it in ArcGIS.

I also tried the revese process, i.e. creating the metadata entries manually in ArcGIS (by editing the data source item description) and loading up the raster in Python with gdal. However, I can't find the metadata when I try the ds.GetMetadata() command, and in fact am struggling to find it anywhere in the object at all. I thought that the metadata might be stored in the band, however band.GetMetadata yields nothing either.


You should look at the GeoTIFF specification on the GDAL page, which is copied below.

You likely need to use a very-well defined metadata label to ensure inter-comprehension between programs. The metadata tag "description" should be "TIFFTAG_IMAGEDESCRIPTION".


GDAL can deal with the following baseline TIFF tags as dataset-level metadata :


The name of the metadata item to use is one of the above names ("TIFFTAG_DOCUMENTNAME", ...).

Other non standard metadata items can be stored in a TIFF file created with the profile GDALGeoTIFF (the default, see below in the Creation issues section). Those metadata items are grouped together into a XML string stored in the non standard TIFFTAG_GDAL_METADATA ASCII tag (code 42112). When BASELINE or GeoTIFF profile are used, those non standard metadata items are stored into a PAM .aux.xml file.

  • Thanks for the answer, but unfortunately the documentation is not very friendly for a newbie like me. In the above, I tried changing: ds.SetMetadata({'description':'test description'}) to: ds.SetMetadata({'TIFFTAG_IMAGEDESCRIPTION': 'test description'}) but am still unable to see the metadata in ArcGIS – EngStan Oct 14 '16 at 15:12
  • @EngStan Sorry, I don't have Arc to help troubleshoot. I did notice that trying to use the more strict creation profiles didn't actually create the .aux.xml file like the documentation said it would.... – Logan Byers Oct 14 '16 at 20:48

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.