[GRASS-dev] strange mapcalc behavior again

I wrote about this a week or two ago. I thought it was a fluke. But now it is happening again.

I've attached an output graphic of a couple maps. The base map is of the Mediterranean Sea, called "oceans". The colored areas have a value of 1, the white have a value of null. Over this is a map called 'clipper'. The red areas of clipper have a value of 1, the rest are null. I've also use r.null to make alternate versions of the oceans map and clipper where the null values are replaced by -99.

The following mapcalc statement creates a complete null map.

r.mapcalc 'oceans_clipped=if(clipper==1, null(), oceans)'

The following mapcalc statement creates a map of all -99 values (using the alternate versions of the maps with null values replaced by -99).

r.mapcalc 'oceans_clipped2=if(clipper2==1, -99, oceans2)'

Somehow, the 2nd part of the if clause is being ignored. I've done this in GRASS 6.5 and 7 with the same results (with the changed of syntax needed for GRASS 7). Am I missing something here?

Michael

[cid:B6FA1F29-0B6E-495D-B7BB-F1532D163749@domain.actdsltmp]

____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

(attachments)

overlaymaps.png

Michael Barton wrote:

Somehow, the 2nd part of the if clause is being ignored. I've done
this in GRASS 6.5 and 7 with the same results (with the changed of
syntax needed for GRASS 7). Am I missing something here?

If such a fundamental error existed in r.mapcalc itself, I'm fairly
sure that you wouldn't be the only person seeing it. So it would seem
to be a problem with your system, your GRASS build, or your data.
Unfortunately, I have no idea what.

Do you get odd results for any module other than r.mapcalc?

--
Glynn Clements <glynn@gclements.plus.com>

No I don't.

It happens on different computers. But since I've compiled it, the problem could lie there. This is a fairly recent phenomenon or I would have reported it long ago. I don't know how recent, however, since I don't remember the other times I've tried to use an if statement like this (i.e., when it worked, I would not have noticed any problems).

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Jul 28, 2011, at 12:03 PM, Glynn Clements wrote:

Michael Barton wrote:

Somehow, the 2nd part of the if clause is being ignored. I've done
this in GRASS 6.5 and 7 with the same results (with the changed of
syntax needed for GRASS 7). Am I missing something here?

If such a fundamental error existed in r.mapcalc itself, I'm fairly
sure that you wouldn't be the only person seeing it. So it would seem
to be a problem with your system, your GRASS build, or your data.
Unfortunately, I have no idea what.

Do you get odd results for any module other than r.mapcalc?

--
Glynn Clements <glynn@gclements.plus.com>