[gdal-dev] I cannot clean overviews from GeoTIFF
Rahkonen Jukka
jukka.rahkonen at maanmittauslaitos.fi
Mon May 12 07:20:07 PDT 2025
Hi,
So now we have the right question: how to remove overviews from cloud optimized GeoTIFF.
First confirm your findings:
gdal_create -of cog -outsize 1000 1000 cog.tif
0...10...20...30...40...50...60...70...80...90...100 - done.
test1:
gdaladdo cog.tif
ERROR 6: cog.tif: Cannot add external overviews when there are already internal overviews
Overview building failed.
test2
gdaladdo -clean cog.tif
ERROR 6: cog.tif: Cannot add external overviews when there are already internal overviews
Cleaning overviews failed.
All right, COG is a GeoTIFF and only metadata tells that it is also COG
Image Structure Metadata:
LAYOUT=COG
COMPRESSION=LZW
INTERLEAVE=BAND
So, let's try to remove the metadata. No success but an interesting message:
gdal_edit -unsetmd cog.tif
File cog.tif has C(loud) O(ptimized) G(eoTIFF) layout. Updating it will generally result in losing part of the optimizations (but will still produce a valid GeoTIFF file). If this is acceptable, open the file with the IGNORE_COG_LAYOUT_BREAK open option set to YES.
Let's try the suggested option:
gdaladdo -clean cog.tif -oo IGNORE_COG_LAYOUT_BREAK=yes
Success!
Now it is your turn to suggest improvements to COG driver manual page and to the error messages of gdaladdo.
-Jukka Rahkonen-
________________________________________
Lähettäjä: Javier Jimenez Shaw
Lähetetty: Maanantai 12. toukokuuta 2025 16.48
Vastaanottaja: Rahkonen Jukka
Kopio: gdal dev
Aihe: Re: [gdal-dev] I cannot clean overviews from GeoTIFF
Apparently it is related with COG:$ gdal_translate -of COG foo.tif foo.cog.tifInput file size is 1000, 10000...10...20...30...40...50...60...70...80...90...100 - done.$ gdaladdo -clean --debug ON foo.cog.tif GDAL: GDALOpen(foo.cog.tif, this=0x15900ae00) succeeds as GTiff.GTiff: ScanDirectories()GTiff: Opened 500x500 overview.GTiff: File open for read-only accessing, creating overviews externally.ERROR 6: foo.cog.tif: Cannot add external overviews when there are already internal overviewsCleaning overviews failed.GDAL: GDALClose(foo.cog.tif, this=0x15900ae00)
More information about the gdal-dev
mailing list