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

[Bug] r.neighbors doesn't consider the mask #4780

Open
mazingaro opened this issue Nov 28, 2024 · 2 comments
Open

[Bug] r.neighbors doesn't consider the mask #4780

mazingaro opened this issue Nov 28, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mazingaro
Copy link

mazingaro commented Nov 28, 2024

When using r.neighbors in GRASS GIS 8.4 (Debian 12), the module does not respect the active mask. Despite applying a mask, r.neighbors computes values for masked areas.
Documentation for r.neighbors:
"Ther.neighbors program works in the current geographic region with the current mask, if any."

Reproduce with any raster like this. Tested for mode and average methods.

r.mask raster=raster_for_masking@MAPSET
r.neighbors input=raster@MAPSET output=raster2@MAPSET size=15 method=mode memory=30000
r-mask -r

Screenshot of the masked area. The operation was performed after masking.
Screenshot_20241128_142625

Screenshot of the result with the removed masked
Screenshot_20241128_142640

@mazingaro mazingaro added the bug Something isn't working label Nov 28, 2024
@ninsbl
Copy link
Member

ninsbl commented Dec 11, 2024

My understanding is that the behavior you see is from the current design of how the MASK works in general. It is used/applied only when reading data, not on write. So the masked pixels that have any valid data within the moving window receive values when the result is written. As of now, you would have to remove those pixels in a second step if that is the result you want. I think there was a feature request for MASK on write, but I cannot find it right now...

@mazingaro
Copy link
Author

mazingaro commented Dec 11, 2024

@ninsbl
Thank you for this feedback.
I understand that, but does this mean that the documentation should be improved?
"Ther.neighbors program works in the current geographic region with the current mask, if any."

The meaning of "with the current mask" can be ambiguous. I understand it as it writes. If there would me no mask mentioned it wouldn't raise no doubts, cause the mask, as you stated, is used to read.

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

No branches or pull requests

2 participants