Closed JosefWN closed 1 year ago
TIFF image contains netcdf attributes of the original data, which had _FillValue=nan
, but image itself is rgba (using Palette)
Band 1 Block=2432x3 Type=Byte, ColorInterp=Palette
NoData Value=nan
Metadata:
actual_range={0,120}
long_name=z
NETCDF_VARNAME=z
_FillValue=nan
Color Table (RGB with 256 entries)
When coercing _FillValue
attribute to the actual output dtype of uint8
things break:
I would put a try:except guard on that conversion and leave attribute unchanged if casting fails for whatever reason, maybe with a warning, maybe silent.
This is an unexpected scenario. Sounds like you have an invalid file.
I am leaning towards addressing this issue by removing the _FillValue
if riods.nodata
is None here:
https://github.com/corteva/rioxarray/blob/4c0aef19ad0c4ff81d94395eb62b605738a7b26c/rioxarray/_io.py#L657-L659
if riods.nodata is not None:
# The nodata values for the raster bands
attrs["_FillValue"] = riods.nodata
else:
attrs.pop("_FillValue", None)
See #667
Code Sample, a copy-pastable example if possible
Problem description
Expected Output
Would expect something in line with
xarray.open_rasterio
rather than crashing.Environment Information
Installation method
Homebrew