-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
raster: Read raster for mask from env variable #2392
Conversation
Use environment variable GRASS_MASK to obtain the name of the raster map to use as raster map for auto-masking. Mask can be in another mapset. If it does not exist, mask is not applied. The direct masking rules for values (zero and null is masked out) apply (as when using `g.copy raster=xxx,MASK`). This is implemented as an alternative to using r.mask, i.e., r.mask does not get the name from the environment variable. Setting and unsetting is done by manipulating the environment variable. This is analogous to GRASS_REGION which cannot be manipulated by g.region and similar to g.copy used for MASK which cannot be mixed with r.mask -r.
@wenzeslaus Please provide details on what is missing in order to review this PR? |
On many places (more than covered here), 2D raster mask is called MASK conflating the concept (mask) and the implementation (MASK raster). Users using the r.mask tool may not interact with the underlying raster directly, so there is no reason to use MASK over mask. This is leaving many places as they are with MASK. Some will be better revisited with or after OSGeo#2390 and OSGeo#2392 when a more comprehensive solution is available. This fixes and keeps in sync wording r.null and r.external, and moves r.circle comment documenting the interface to a flag description.
To avoid asking about presence of the MASK raster, add a library function which checks for presence of the raster hiding its name in the library. This prepares way for OSGeo#2392. This also changes the message from using MASK to simply mask. I'm open to suggestion on wording of 'mask is present' versus 'mask is active' etc.
On many places (more than covered here), 2D raster mask is called MASK conflating the concept (mask) and the implementation (MASK raster). Users using the r.mask tool may not interact with the underlying raster directly, so there is no reason to use MASK over mask. This is changing MASK to mask and modifies related wording. However, this is also leaving many places as they are with MASK. Some will be better revisited with or after #2390 and #2392 when a more comprehensive solution is available. This fixes and keeps in sync wording in r.null and r.external, and moves r.circle comment documenting the interface to a flag description.
Documentation updated both to reflect the latest review and to use Markdown. This is now ready for a new round of reviews. Please, review the |
CMake fails with:
|
There is testreport as artefact to the cmake workflow, a bit tedious to compare. Perhaps better to use a test config file instead of per cent success. |
|
|
Thanks @nilason. I just assumed config is used for tests, so I thought all the unrelated failures are not on main. Fixed now. I saw that earlier, but it was great to experience that no boilerplate is needed for adding a tool to CMake. |
This and 21 other PRs made a small revolution in how raster mask can be used in GRASS (multiple masks, masks in other mapsets, set and unset without r.mask or creating and deleting raster) as well as in how mask is presented to the user (no more MASK in the doc to refer to "all things mask"). This will be part of upcoming v8.5, so please test. Basic documentation and tests provided, see especially: |
Use environment variable GRASS_MASK to obtain the name of the raster map to use as raster map for auto-masking. The name defaults to MASK in the current mapset. Otherwise, the behavior follows the same rules.
Mask can be in another mapset. If it does not exist, mask is not applied. The direct masking rules for values (zero and null is masked out) apply (as when using
g.copy raster=xxx,MASK
).It works with r.mask, i.e., r.mask gets the name from the environment variable. While setting and unsetting can be done only by manipulating the environment variable, r.mask will use whatever is the mask name set by the environment variable or the default name. This allows to fully use the r.mask capabilities without a need to reimplement them somewhere else. It will also keep the workflows with and without the variable same, so all the r.mask documentation applies to the advanced case of using the variable. If the mask set by the environment is in a different mapset, r.mask will fail.
An alternative would be to implement this without r.mask, i.e., r.mask does not get the name from the environment variable. Setting and unsetting this mask would be done only by manipulating the environment variable. This would be analogous to GRASS_REGION which cannot be manipulated by g.region and similar to g.copy used for MASK which is not easily mixed with r.mask. However, while GRASS_REGION says what the computational region should be, GRASS_MASK merely says what the mask name is regardless of its presence. We could fail if the raster is not present, but it seems more natural to behave the same as with the default name (MASK). This discussion then leads to the current implementation where r.mask respects whatever GRASS_MASK says.
r.fillnulls and r.in.wms are Python scripts which need to handle mask in a special way. The new functionality makes the implementation simpler and it makes the tools more robust as they don't touch the global mask state anymore. The new implementation is included here.
C library:
Python library:
Tools:
Tests:
Documentation:
As part of the Markdown transition, it updates the Markdown doc with new content, but also the originally modified HTML files.
Review or revise code in this PR:
Code changes implemented elsewhere:
Use variable:
Use r.mask.status tool:
Update doc inside this PR:
Update doc outside of this PR:
Changes needed: