I'm trying to set geolocation metadata in a gdal vrt with python bindings.
ds = gdal.Open('foo')
ds.SetMetadata ({'X_BAND' : '1'})
gdal.BuildVRT('bar', ds)
Results in a vrt with the following metadata
<Metadata>
<MDI key="X_BAND">1</MDI>
</Metadata>
However, I need the metadata to read:
<Metadata domain="GEOLOCATION">
<MDI key="X_BAND">1</MDI>
</Metadata>
I'm able to accomplish this using ds.SetMetaDataItem("X_BAND", "1", "geolocation")
but would like to know how to do it with gdal.SetMetadata
I know the problem is with my failure to understand how swig is translating the python to the C++ so hopefully someone can quickly fix my syntax. From http://gdal.org/python/
SetMetadata(self, *args)
SetMetadata(self, char papszMetadata, char pszDomain = "") -> CPLErr
SetMetadata(self, char pszMetadataString, char pszDomain = "") -> CPLErr
-
Yes! That did it (as long as the "1" is in quotes). If you post this as an answer I will accept, thanks.bbuzz31– bbuzz312018年03月19日 20:44:15 +00:00Commented Mar 19, 2018 at 20:44
1 Answer 1
You can do this by passing a dict:
ds.SetMetadata({"X_BAND": "1" }, "GEOLOCATION")