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

v.surf.idw: fix applying mask #2383

Merged
merged 1 commit into from
May 20, 2022
Merged

Conversation

petrasovaa
Copy link
Contributor

v.surf.idw doesn't apply mask properly, it works only when the mask has value 0, not null. So when you create mask with r.mask, v.surf.idw ignores that and interpolates for those values as well.

See also https://trac.osgeo.org/grass/ticket/3677 (not sure why I couldn't reproduce it there.)

@petrasovaa petrasovaa added bug Something isn't working backport_needed raster Related to raster data processing C Related code is in C labels May 19, 2022
@petrasovaa petrasovaa added this to the 8.2.0 milestone May 19, 2022
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

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

This looks good. The right test for "is cell masked out" according to lib/raster/get_row.c is

mask_row_buffer[i] == 0 || Rast_is_c_null_value(&mask_row_buffer[i])

so exactly what the new code does.

The code uses Rast_get_c_row while Rast_get_c_row_nomask might be more appropriate for reading mask and more aligned with the internal code for applying mask and perhaps little faster, too, since there is no masking step. As far as I understand, using Rast_get_c_row makes the mask[col] == 0 part of the test useless because zeros were already converted to nulls in Rast_get_c_row. When Rast_get_c_row_nomask is used, mask[col] == 0 is appropriate because that's the correct masking method.

@petrasovaa petrasovaa merged commit 0b22155 into OSGeo:main May 20, 2022
@petrasovaa petrasovaa deleted the v.surf.idw-mask branch May 20, 2022 03:23
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
neteler pushed a commit to nilason/grass that referenced this pull request Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working C Related code is in C raster Related to raster data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants