-
Notifications
You must be signed in to change notification settings - Fork 41
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
Preserve nodata in masked_array
or Raster
subclass during Coreg
operations
#225
Comments
@adehecq I think this is closed by GlacioHack/geoutils#257, right? |
So I'm not sure I understand. Can it be simplified now or not? |
I have updated the top comment with a reproducible example. @adehecq For keeping a written trace on this: arithmetic overloading works! The issue is about the propagation of NaNs during # If the DEM was a masked_array, copy the mask to the new DEM
if hasattr(dem, "mask"):
applied_dem = np.ma.masked_array(applied_dem, mask=dem.mask) # type: ignore
# If the DEM was a Raster with a mask, copy the mask to the new DEM
elif hasattr(dem, "data") and hasattr(dem.data, "mask"):
applied_dem = np.ma.masked_array(applied_dem, mask=dem.data.mask) # type: ignore
# If the input was a Raster, return a Raster as well.
if isinstance(dem, gu.Raster):
return dem.from_array(applied_dem, transform, dem.crs, nodata=dem.nodata) As we just discussed, this is also linked to GlacioHack/geoutils#231 and other various nodata issues |
I see. I get a similar issue with nodata handling (#239). I'll try to look into that and solve it this afternoon if I can. |
EDIT with reproducible example (of NaNs created by
Coreg
but not masked), while bothreference_raster
andto_be_aligned_raster
are fine:For opening issue: we don't want to repeat this operation after every
Coreg
operation to preserve nodata along calculations:Originally posted by @rhugonnet in #224 (comment)
The text was updated successfully, but these errors were encountered: