[GRASS-dev] Issue with double conditional in r.mapcalc (WinGRASS) and real life test of the aconda 7.5dev on Mac

Vaclav Petras wenzeslaus at gmail.com
Sun Feb 18 16:55:48 PST 2018

Hi Yann,

great to hear that you had at least some success. Hopefully the following
info will help you narrow down the issue.

On Sun, Feb 18, 2018 at 2:45 PM, Yann Chemin <dr.yann.chemin at gmail.com>

> I conducted a GRASS GIS course this week and we found some bugs on
> r.mapcalc expression=if(case1,if(case2,Val2True,Val2False),Val1False))

The example lacks the name of the map. Is this intentional? See suggestions
in the manual page, maybe it will explain some details (note the
differences to G6):


I don't know why the nested if statement/function would make any
difference. What else you have tried?

> This expression will fail, note that the lack of quote is intentional, as
> it is a requirement to run simpler r.mapcalc statements in WinGRASS.

I think quotes are basically required since spaces around equal sign are
basically required. See the above links. Perhaps more explanation is needed
in the manual. It explicitly talks about single quotes and unix, but not
about Win or why (or why not double quotes). The things about equal sign
and spaces were added by me to clarify the differences between G6 and G7
syntax, but I did not focus on the Win vs unix differences there.

When in doubts on Win, there is always the GUI Map Calculator which accepts
the right-hand side of the expression.

On bug which is in GUI, which may or may not be reported, is that the
history eats quotes from the command, so reusing the commands needs
additional care.

> Also, we found that the use of || and && within a simple conditional
> statement also did not process anything and failed.

We had issues in the past in our courses with running r.mapcalc commands on
Win because of these, but recently, we had no issues and we settled on the
following syntax (examples from class):

r.mapcalc "elev_combined = if(y() < 224274. && x() > 637455., elevation,

r.mapcalc "low_elev_developed = if((elevation < 100 && elevation > 60) &&
(landuse96_28m == 1 || landuse96_28m == 2),1,null())"

r.mapcalc "urban1_30m = if(landuse96_28m == 1,1,0) + if(landuse96_28m ==

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20180218/5a96312d/attachment.html>

More information about the grass-dev mailing list