[gdal-dev] Adding datasets to VRT at runtime

Even Rouault even.rouault at spatialys.com
Sat Mar 21 02:46:54 PDT 2020


On vendredi 20 mars 2020 17:18:33 CET Mike wrote:
> Currently I have a workflow which uses GDALBuildVRT (in C++) to create a
> dataset with multiple geotiffs. I'm trying now to figure out if after this
> VRT dataset was created, is there a way to add an additional dataset
> without having to call GDALBuildVRT again?
> 
> The main use case for this is I'm that loading geotiffs based on a paging
> system, and I'd like to be able to efficiently handle adding these new
> datasets. Any suggestions for where to look or maybe a different method is
> appreciated too.

Mie,

https://gdal.org/drivers/raster/vrt.html#creation-of-vrt-datasets gives an 
example on how to add a new source with
oBand->SetMetadataItem( "source_0", szFilterSourceXML, "vrt_sources" );
You'd need to adapt the XML to use a SimpleSource or ComplexSource.

Otherwise a VRT is just a XML file, so you can also use your favorite XML 
editing library
(or GDAL's minixml : https://gdal.org/doxygen/cpl__minixml_8h.html ) to edit 
it as you wish.

Even


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


More information about the gdal-dev mailing list