[GIS] Set Metadata domain with GDAL (python bindings)

cgdalgeolocationpython

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

Best Answer

You can do this by passing a dict:

ds.SetMetadata({"X_BAND": "1" }, "GEOLOCATION")