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

Wrong behaviour of copy() method with new_array from np.ndarray with NaNs #294

Closed
rhugonnet opened this issue Sep 4, 2022 · 0 comments · Fixed by #300
Closed

Wrong behaviour of copy() method with new_array from np.ndarray with NaNs #294

rhugonnet opened this issue Sep 4, 2022 · 0 comments · Fixed by #300
Labels
bug Something isn't working

Comments

@rhugonnet
Copy link
Contributor

rhugonnet commented Sep 4, 2022

The copy method expects a np.ndarray as input for the new_array argument. However, if that array contains NaNs, the Raster object created will have as .data a np.ma.masked_array which contains unmasked NaNs.

This results in a lot of issues: applying np.ma functions, writing a Raster to disk in rasterio, propagating nodata when applying arithmetic functions to Raster objects, etc... Strangely, some systems support the writing of these unmasked NaNs to disk in TIFF, while it result in a break down on others.

We should probably check the input type in copy, or upstream in from_array i.e. in Raster.__init__ if the issue is global to these routines, in order to create a masked_array that masks the NaNs automatically.

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.

1 participant