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

Add a masking functionality #271

Merged
merged 18 commits into from
May 18, 2022
Merged

Add a masking functionality #271

merged 18 commits into from
May 18, 2022

Conversation

adehecq
Copy link
Member

@adehecq adehecq commented May 11, 2022

This is in reply to issue #235.
I added a new method to Raster to set the data mask.

Example:

import geoutils as gu
r = gu.Raster(gu.datasets.get_path(dataset))
mask = (r.data == 126)
r.set_mask(mask)
r.show(cmap='gray')

Copy link
Member

@rhugonnet rhugonnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! This will be super useful 👍. Doing this operation for masked arrays (especially within another object) is not something intuitive for all.
I have only a little comment on the tests: we could add an assertion using np.array_equal to check that the exact content of the mask is preserved? Right now if I got it right, it's only the counts.

@adehecq
Copy link
Member Author

adehecq commented May 11, 2022

I have only a little comment on the tests: we could add an assertion using np.array_equal to check that the exact content of the mask is preserved? Right now if I got it right, it's only the counts.

Good point ! Especially when testing that the previous mask is preserved. Summing the count works if the two masks do not overlap (which is the case here), otherwise not...
Fixed with c2fe2a1.

@adehecq
Copy link
Member Author

adehecq commented May 11, 2022

While I was on it, I also fixed issue #233.

@adehecq adehecq merged commit c101c3e into GlacioHack:main May 18, 2022
@adehecq adehecq deleted the mask branch May 18, 2022 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consistent masking of Raster object Raster.save does not take into account mask.
2 participants