Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean internal overviews but file size not change #10551

Closed
ningfc opened this issue Aug 6, 2024 · 5 comments
Closed

Clean internal overviews but file size not change #10551

ningfc opened this issue Aug 6, 2024 · 5 comments

Comments

@ningfc
Copy link

ningfc commented Aug 6, 2024

What is the bug?

File size not change after remove internal overviews with command gdaladdo -clean filename.tif

Steps to reproduce the issue

  1. Run gdaladdo -clean filename.tif from command
  2. Check file size , not change.
  3. Then run gdaladdo filename.tif
  4. Check file size , increased
  5. Repeat 1-4, file size will increase every time, but not decrease.

Versions and provenance

v3.8.3

Additional context

No response

@jratike80
Copy link
Collaborator

You probably did not see this part of the documentation https://gdal.org/programs/gdaladdo.html

For internal GeoTIFF overviews (or external overviews in GeoTIFF format), note that -clean does not shrink the file. A later run of gdaladdo with overview levels will cause the file to be expanded, rather than reusing the space of the previously deleted overviews. If you just want to change the resampling method on a file that already has overviews computed, you don't need to clean the existing overviews.

@ningfc
Copy link
Author

ningfc commented Aug 8, 2024

Oh, thanks. I got it. But do you feel it's weird?
I think, Allowing to shrink the file size is better. So I guess gdaladdo doesn't shrink file size, maybe had considered it for some reason. I have an idea, we can add a new command config like -purge to shrink file size.
Now if I want to shrink the file size, I use gdal_translate to export a new file. but it takes expend long time if the file is large.

@tbonfort
Copy link
Member

tbonfort commented Aug 8, 2024

if your geotiff is tiled, you should be able to use github.com/airbusgeo/cogger for a very fast rewrite reclaiming space. (the output will be a cog, but a geotiff also nonetheless)

@jratike80
Copy link
Collaborator

Oh, thanks. I got it. But do you feel it's weird?

I guess that gdaladdo -purge would be as slow as gdal_translate because it would also need to rewrite all the data. As far as I know "clean" just updates the offsets of the image file directories of the overviews.
If you need to remove overviews frequently for example when testing resampling methods, use external overviews.

@tbonfort
Copy link
Member

tbonfort commented Aug 9, 2024

I have opened airbusgeo/cogger#13 in order to further support geotiff cleaning with cogger. If you have any other ideas you can add them over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants