the reference answer GPT ᴼ ᴾ ᴱ ᴺ ᴬ ᴵ < br / > an error prompt already exists within the pyramid, unable to add external pyramid, if need to delete the internal pyramid, can use gdaladdo command, For example:
import os
import subprocess
# 执行 gdaladdo 命令删除内部金字塔
subprocess.call(["gdaladdo", "-clean", r"D:\项目\GF02_PA1_023116_20181128_MY450_01_096_L1A_01_PSH.tif"])
# 打开数据集并建立外部金字塔
dataset = gdal.Open(r"D:\项目\GF02_PA1_023116_20181128_MY450_01_096_L1A_01_PSH.tif", gdal.GA_Update)
dataset.BuildOverviews("AVERAGE", [2, 4, 8, 16, 32])
dataset = None # 关闭数据集
Here, use the -clean parameter of the gdaladdo command to remove the inner pyramid, then use BuildOverviews to build the outer pyramid.