[GRASS-user] r.mapcalc: collection of values

Glynn Clements glynn at gclements.plus.com
Tue Jun 26 11:56:01 PDT 2012


bei wrote:

> I am trying to create a map combining two maps. Each category in the final
> map will depend on the value in the other two.  I will do it using nested
> "if". I have already done this kind of "if": 
> aed06_p_3= if(a06_p_2 == 243, if(arb_p >= 20, 10, if(arb_p < 10, 20, 
> 33)), if(a06_p_2 == 244, if(arb_p >= 20, 10, if(arb_p < 10, 
> 31, 33)), if(a06_p_2 == 324, if(arb_p >= 20, 10, if(arb_p < 
> 10, 32, 33)), a06_p_2)))
> 
> But now, instead of one value for a06_p_2 I will have various possible
> values (more than 5), so the nested if is geeting too long.
> 
> I would like to know if there is an option shorter than writting a
> collection of "OR": a06_p_2==243 | a06_p_2==234 | a06_p_2==245 |
> a06_p_2==246
> 
> a way to collect all the values, maybe something similar to a06_p_2 IN
> (243,244,245,246)

There isn't an "in" operator.

Also, from your description, you might be better off using r.cross and
r.reclass.

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


More information about the grass-user mailing list