I'd like to set a metadata value within a shapefile using Python bindings. I'm using the SetMetaData() / GetMetaData() methods within GDAL (gdal.org/python/osgeo.ogr.MajorObject-class.html). I've had no problem with raster files, but when I go to do the same with shapefiles, it will update the datasource while it's open, but won't save them if it's closed.
ds = ogr.GetDriverByName('ESRI Shapefile').Open('C:/Polygons.shp', 1)
print( ds.GetMetadata() )
ds.SetMetadata( {'ThisKey':'ThisValue'} )
print( ds.GetMetadata() )
ds.Destroy()
del ds
ds = ogr.GetDriverByName('ESRI Shapefile').Open('C:/Polygons.shp', 1)
print( ds.GetMetadata() )
ds.Destroy()
del ds
produces
{}
{'ThisKey': 'ThisValue'}
{}
I can't see what I'm doing wrong.