[gdal-dev] [Python bindings] BuildOverviews() not supported for VRT dataset
umbertofilippo
umbertofilippo at tiscali.it
Fri Feb 7 02:58:02 PST 2020
Solved by looking at this answer
<https://gis.stackexchange.com/questions/44003/python-equivalent-of-gdalbuildvrt/299218>
:
out_vrt = os.path.join(out_dir, 'mosaic.vrt')
ds = gdal.BuildVRT(out_vrt, [raster1.tif, raster2.tif])
ds = None # this did the trick!
factors = [128, 256, 512]
gdal.SetConfigOption('COMPRESS_OVERVIEW', 'DEFLATE')
ds.BuildOverviews("AVERAGE", factors)
Explanation (quoting one of the comments in the answer I mentioned):
"Note that the CreateCopy() method returns a writable dataset, and that it
must be closed properly to complete writing and flushing the dataset to
disk. In the Python case this occurs automatically when "dst_ds" goes out of
scope." SInce there is no closing for python, you have to bring your vrt out
of scope, by assign it to None.
--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
More information about the gdal-dev
mailing list