You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to clip an int32 DataArray object x using the x.rio.clip() method, the following error is thrown:
python3.12/site-packages/xarray/core/duck_array_ops.py:201: RuntimeWarning: invalid value encountered in cast
return data.astype(dtype, **kwargs)
The same call works fine with float32 data, so I'm assuming this is because rioxarray returns NaN for any non-intersecting cells and xarray can't cast those into int32. If my assumptions is correct, and if int dtypes shouldn't be supported for clip, then I think it could be beneficial to check whether self._obj.dtype is NaN-friendly and follow-up with a useful error message if it's not. Something along the lines of:
ValueError: int32 data is not supported for clip, data type must be float.
Description
When trying to clip an int32 DataArray object
x
using thex.rio.clip()
method, the following error is thrown:The same call works fine with float32 data, so I'm assuming this is because rioxarray returns NaN for any non-intersecting cells and xarray can't cast those into int32. If my assumptions is correct, and if int dtypes shouldn't be supported for clip, then I think it could be beneficial to check whether
self._obj.dtype
is NaN-friendly and follow-up with a useful error message if it's not. Something along the lines of:Example
The text was updated successfully, but these errors were encountered: