r.mapcalc: collection of values

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
bei
Reply | Threaded
Open this post in threaded view
|

r.mapcalc: collection of values

bei
Hi,

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)

Thanks a lot
Reply | Threaded
Open this post in threaded view
|

Re: r.mapcalc: collection of values

Glynn Clements

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 <[hidden email]>
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user