简体   繁体   中英

How to build Internal Overviews with Python gdal BuildOverviews()?

Trying to mimic the result of running gdaladdo -r average "D:\\image.tif" using python gdal bindings. When I run the code below, I get an external .ovr file. How can I generate an internal overview? Am I using the correct function to mimic gdaladdo?

from osgeo import gdal
InputImage = r"D:\image.tif"

Image = gdal.Open(InputImage,1)
Image.BuildOverviews("AVERAGE", [2,4,8,16,32,64])

I've also tried

Image = gdal.Open(InputImage, gdal.GA_Update)

This worked for me:

Image = gdal.Open('example.tiff', 1)
gdal.SetConfigOption("COMPRESS_OVERVIEW", "DEFLATE")
Image.BuildOverviews("AVERAGE", [2,4,8,16,32,64, 128, 256])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM