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)
out_band.WriteArray(data)
del ds
If you load the test data, you will see that the metadata has indeed been set:
ds = gdal.Open(fname)
ds.GetMetadata()
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.
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