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

COG convesion succeeds with GDAL but not with rio-cogeo #250

Open
vatsa-asteria opened this issue Dec 5, 2022 · 4 comments
Open

COG convesion succeeds with GDAL but not with rio-cogeo #250

vatsa-asteria opened this issue Dec 5, 2022 · 4 comments

Comments

@vatsa-asteria
Copy link

I've a couple of rasters of pixel dimensions like 300k x 150k. Most of the pixels have NODATA values. The data looks like below
image

The file size with LZW compression is 7 GB. When I use following GDAL commands to convert to COG, conversion happens in around an hour:

$ gdal_translate source.tif tmp.tif -co TILED=YES -co COMPRESS=DEFLATE -co BIGTIFF=IF_SAFER -co COPY_SRC_OVERVIEWS=YES
$ gdaladdo tmp.tif 2 4 8 16 32
$ gdal_translate tmp.tif cog.tif -co TILED=YES -co BIGTIFF=IF_SAFER -co COPY_SRC_OVERVIEWS=YES

But if I run rio cogeo create source.tif cog.tif, conversion gets stuck at -

Reading input: <file path>
  [------------------------------------]    0%  2d 19:51:43

I tried multiple times and killed the process after couple of hours.

I believe the method vrt_dst.read() of class WarpedVRT is trying to unpack the raster (which is originally in LZW compression). Uncompressed file would come around 200 - 300 GB. This could be causing the conversion to take days instead of an hour.

@vincentsarago
Copy link
Member

vincentsarago commented Dec 5, 2022

@vatsa-asteria thanks for the issue
can you try with

rio cogeo create source.tif cog.tif -p LZW --co BIGTIFF=IF_SAFER --no-in-memory --allow-intermediate-compression --co SPARSE_OK=TRUE

Note: if you have gdal>3.1 there is no real advantage of using rio-cogeo over GDAL for the conversion you're trying to do

@vatsa-asteria
Copy link
Author

vatsa-asteria commented Dec 5, 2022

@vincentsarago with above command too, I still see the same message

Reading input: <file path>
  [------------------------------------]    0%  2d 20:58:42

[EDIT]:
https://gdal.org/drivers/raster/cog.html mentions SPARSE_OK=TRUE/FALSE requires GDAL >= 3.2. I'm using 3.1. I'll upgrade GDAL and try.

@vincentsarago
Copy link
Member

vincentsarago commented Dec 5, 2022

👍 , you're COG is definitely SPARSE so 3.2 will be a huge improvement

Not sure it will change anything for rio-cogeo

@vatsa-asteria
Copy link
Author

Upgrading GDAL didn't help either. It still shows over 2-3 days as reading time.

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

2 participants