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

Write specific functions to collapse/rebuild input/outputs as Raster, np.ma.masked_array or np.ndarray consistently #293

Open
rhugonnet opened this issue Aug 26, 2022 · 4 comments
Labels
priority Needs to be fixed rapidly

Comments

@rhugonnet
Copy link
Contributor

rhugonnet commented Aug 26, 2022

We have tons of "wrapper" functions that can take either Raster, np.ma.masked_array or np.ndarray as input, but then only work on the np.ndarray (and possibly some metadata), and for output rebuild a Raster, np.ma.masked_array or np.ndarray to match the input.
Right now this is done semi-manually everywhere, we need to have consistent input/output functions for those conversions. Might be triggering issues in #291 due to GlacioHack/geoutils#265.

@rhugonnet rhugonnet added the priority Needs to be fixed rapidly label Aug 1, 2023
@erikmannerfelt
Copy link
Contributor

That's a good idea. A small problem right now (or an unintended feature) is that all metadata are lost after raster recreation. Only the CRS and transform are identical to the input.

@adehecq
Copy link
Member

adehecq commented Sep 6, 2023

@rhugonnet, could you add here the few lines of code that are repeated each time? Is it more than just 1-2 lines of code?

@rhugonnet
Copy link
Contributor Author

Yes, the 10 lines in Coreg.apply() for "reconstructing" for example: https://github.com/GlacioHack/xdem/blob/main/xdem/coreg/base.py#L1160

@rhugonnet
Copy link
Contributor Author

We could do the same to construct masks from a Vector, a Mask, an array, etc... It is used everywhere!
Something like this: https://github.com/GlacioHack/xdem/blob/main/xdem/spatialstats.py#L593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority Needs to be fixed rapidly
Projects
None yet
Development

No branches or pull requests

3 participants