Open remi-braun opened 4 days ago
Hello,
With numpy <2, save_cog_with_dask fails because illegal casting.
save_cog_with_dask
OverflowError: Python integer 999999 out of bounds for uint8
TypeError: Cannot cast scalar from dtype('int64') to dtype('uint8') according to the rule 'same_kind'
This issue is based on this discussion: https://discourse.pangeo.io/t/save-cog-with-dask-cannot-convert-fill-value-999999-to-dtype-uint8/4713/9
As @maxrjones said there:
This is most likely coming from NumPy’s defaults for masked arrays - numpy.ma.default_fill_value — NumPy v2.1 Manual.
Minimal working example:
import numpy as np import rioxarray as rxr from odc.geo import cog, xr # noqa xds = rxr.open_rasterio(r"not_cog.tif", chunks=True) nodata = 0 cog.save_cog_with_dask( xds.copy(data=xds.fillna(nodata).astype(np.uint8)).rio.set_nodata( nodata ), r"cog.tif", ).compute()
Data : not_cog.zip
I'm on Windows, maybe this doesn't help...
Maybe linked to https://github.com/numpy/numpy/issues/25677 and more specifically this comment
Hello,
With numpy <2,
save_cog_with_dask
fails because illegal casting.OverflowError: Python integer 999999 out of bounds for uint8
TypeError: Cannot cast scalar from dtype('int64') to dtype('uint8') according to the rule 'same_kind'
This issue is based on this discussion: https://discourse.pangeo.io/t/save-cog-with-dask-cannot-convert-fill-value-999999-to-dtype-uint8/4713/9
As @maxrjones said there:
Minimal working example:
Data : not_cog.zip
I'm on Windows, maybe this doesn't help...