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

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

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/r-mapcalc-collection-of-values-tp4983971.html
Sent from the Grass - Users mailing list archive at Nabble.com.

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@gclements.plus.com>