[gdal-dev] gdal.BuildVRT with an empty destination

Even Rouault even.rouault at spatialys.com
Wed Mar 13 02:37:34 PDT 2019


On mardi 12 mars 2019 16:42:34 CET Patrick Young wrote:
> Hi all,
> 
> I was browsing some GDAL test cases and came across some tests like so:
> 
> ds = gdal.BuildVRT('',...)
> 
> aka the destination is an empty string.  Is the returned dataset a purely
> in memory object in this case?  I assume it is safe to use like any other
> dataset; some of the other VRT related tests are using "/vsimem/..." as the
> destination, wasn't sure if one form should be prefered over another for
> quick in memory vrt building.
> 

If you use an empty string as the VRT filename, then it is not serialized at 
all when closing it, so you can't reopen it. You must use the dataset handle 
returned by gdal.BuildVRT() directly. Once the handle is closed, all 
associated memory is freed.

If using '/vsimem/foo.vrt', then the VRT XML will be serialized in this 
filename, and you can re-open it later in the same process. And possibly 
gdal.Unlink() the file once done with it to clear memory (if using loops with 
unique filnemames, etc)

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list