GDAL – Troubleshooting Gdal.BuildVRT Not Creating Output

gdalgdalbuildvrtraster-conversion

I am trying to create a mosaic of all the images in file_list, Using:

> vrt_options = gdal.BuildVRTOptions(resampleAlg='cubic', addAlpha=True)
>     gdal.BuildVRT('C:\\my.vrt', file_list, options=vrt_options)

And file_list is a path of all the files i want merged.

 'file_list'
    ['C:\\fasih\\Test_combine\\1974106.mat.tif',
     'C:\\fasih\\Test_combine\\1974107.mat.tif',
     'C:\\fasih\\Test_combine\\1974108.mat.tif',
     'C:\\fasih\\Test_combine\\1974109.mat.tif',
     'C:\\fasih\\Test_combine\\1974110.mat.tif',
     'C:\\fasih\\Test_combine\\1974111.mat.tif',
     'C:\\fasih\\Test_combine\\1974112.mat.tif']

I get this output in Notebook, but nothing is saved in my drive.

<osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at 0x000002180B46F5D0> >

Best Answer

I encountered the same problem. When the vrt is returned as a dataset, you can use this dataset to invoke FlushCache() which made the problem for me disappear. I can remember that this was not necesarry before, but this solved the problem for me.

ds = gdal.BuildVRT('C:\\my.vrt', file_list, options=vrt_options)
ds.FlushCache()
Related Question