I want to add more than one tiff file into a vrt file, Well Based on GDAL documentations it is possible to create a vrt using this code

GDALDriver *poDriver = (GDALDriver *) GDALGetDriverByName( "VRT" );
GDALDataset *poSrcDS, *poVRTDS;
poSrcDS = (GDALDataset *) GDALOpenShared( "utm.tif", GA_ReadOnly );
poVRTDS = poDriver->CreateCopy( "wrk.vrt", poSrcDS, FALSE, NULL, NULL, NULL );
GDALClose((GDALDatasetH) poVRTDS);
GDALClose((GDALDatasetH) poSrcDS);

but it only adds utm.tif. what If I want to add another set of images into this vrt file? can I use poDriver->CreateCopy again and it appends the images into the source vrt?

1 Answer 1


I'm pretty sure that adding

poSrcDS = poDriver->CreateCopy( "wrk.vrt", poSrcDS, FALSE,
                               APPEND_SUBDATASET=YES, NULL, NULL );

before closing the datasets should add the second dataset to the VRT as well.

Hope this helps


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.