1

I'm trying to fetch the XML content of a GDAL Memory VRT raster datasource in Python without saving the datasource to disk. I looked into the GDAL Python API, but have absolutely no idea how to get the VRT XML string.

from osgeo import gdal
ds = gdal.Translate('/vsimem/temp.vrt','C:/Data/myraster.tif','-of VRT')
vrtXmlString = ds.????

1 Answer 1

2

Ok, once again I was too quick with the question. I have just found the answer on the Internet (https://trac.osgeo.org/gdal/ticket/6767). Maybe someone could use it.

from osgeo import gdal
ds = gdal.Translate('/vsimem/temp.vrt','C:/Data/myraster.tif','-of VRT')
vrtXmlString = ds.GetMetadata('xml:VRT')[0]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.