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

RasterIO 1.1.2 'Int64' KeyError When Creating COG file from Jp2 #115

Closed
sachsbl opened this issue Dec 27, 2019 · 5 comments · Fixed by #117
Closed

RasterIO 1.1.2 'Int64' KeyError When Creating COG file from Jp2 #115

sachsbl opened this issue Dec 27, 2019 · 5 comments · Fixed by #117
Labels
bug Something isn't working

Comments

@sachsbl
Copy link

sachsbl commented Dec 27, 2019

So when RasterIO updated to 1.1.2 (December 18th), I started seeing things breaking that worked fine before. Specifically, converting any Sentinel2 jp2 files to COG. I see this error:

File "/usr/lib/python3.7/site-packages/rio_cogeo/cogeo.py", line 259, in cog_translate tmp_dst.write_mask(mask_value, window=w) File "rasterio/_io.pyx", line 1630, in rasterio._io.DatasetWriterBase.write_mask File "rasterio/shim_rasterioex.pxi", line 52, in rasterio._shim.io_band KeyError: 'int64'

This issue is environment specific. On my MacOS (Catalina), this works fine. However, this error occurs when the same code is run against Alpine Linux. Specifically I am using the docker image osgeo/gdal:alpine-normal-3.0.2, which has Python 3.7.5 and GDAL 3.0.2. Again, same setup locally on MacOS works fine. And the same code works fine on Alpine Linux at RasterIO 1.1.1. All of this is latest rio_cogeo. Any insight here would be appreciated!

@vincentsarago
Copy link
Member

Hi @sachsbl thanks for opening this issue.

This is a rasterio error, because int64 is not supported by rasterio (and by gdal too). See: https://github.com/mapbox/rasterio/blob/master/rasterio/dtypes.py#L13-L24

The error message says mask_value returned at line 258 is in type int64 and thus cannot be written in the dataset (L259)

mask_value = vrt_dst.dataset_mask(window=w)
tmp_dst.write_mask(mask_value, window=w)

I guess we could maybe fix this by casting the mask to uint8

@vincentsarago vincentsarago added the bug Something isn't working label Jan 8, 2020
@vincentsarago
Copy link
Member

vincentsarago commented Jan 8, 2020

FYI, I was able to reproduce this error on my mac using gdal2.4 too.

I guess this is due to recent change in rasterio: rasterio/rasterio@1830c6b

cc @sgillies (FYI)

@vincentsarago
Copy link
Member

This will be fixed in rasterio 1.1.3 per rasterio/rasterio@07d47ef

Thanks again for the report @sachsbl

@sachsbl
Copy link
Author

sachsbl commented Jan 8, 2020

thanks for the investigation @vincentsarago! I will await 1.1.3

@vincentsarago
Copy link
Member

Well in fact I'm going to push a quick fix including changes from #114 so we don't have to wait for rasterio :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants