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

混江龙づ霸主 提交于 2020-04-18 00:50:43

问题


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)

回答1:


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])


来源:https://stackoverflow.com/questions/60954617/how-to-build-internal-overviews-with-python-gdal-buildoverviews

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!