-
-
Notifications
You must be signed in to change notification settings - Fork 332
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
r.reclass.area: Add flag to optionally output NULL raster if no areas are left after reclass #1728
base: main
Are you sure you want to change the base?
Conversation
(re-run black) |
@griembauer please see the black formatting error... thanks |
op_str = "less" | ||
else: | ||
op_str = "greater" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original code is right. Sentences cannot be build from parts because that makes translations impossible. If really needed, you could create two sentences and then put them together using another, possibly translatable, string.
_("No areas of size greater than or equal to %f " "hectares found.") | ||
% limit | ||
_("No areas of size %s than or equal to %f " "hectares found.") | ||
% (op_str, limit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve the code overall, please use .format()
when rewriting the messages.
expression = "$outfile = null()" | ||
del mapcalc_kwargs["recfile"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe having two calls of mapcalc would result in a simpler code.
else: | ||
op_str = "greater" | ||
if nodata is True: | ||
grass.warning( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are probably in the best position to decide that, but if user requests NULL raster in those cases, is warning needed? Isn't that a verbose message instead? In other words, the new flag seems to make the the "no areas" state to be a standard state with appropriate output, so why a warning?
grass.run_command( | ||
"g.remove", flags="f", type="vector", name=mapp, quiet=True | ||
) | ||
if grass.find_file(name=mapp, element="vector")["file"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please comment on why you are making this change in the PR description.
The code here needs some changes, but otherwise it is a very good improvement. I'm keeping it open, just moving the milestone. |
Currently,
r.reclass.area
withmethod=reclass
fails if no areas greater or less than the specified value are found. This PR adds a flag to create a NULL-raster as output instead for this case.