0

I would like to know the purpose of a comma in r.mapcalc of GRASS GIS. Consider this example -

r.mapcalc "noise = if(landuse96_28m==1 || landuse96_28m==2, roads_buffers, null())"

In the above example I know the statement means if landuse96_28m is equal to 1 OR landuse96_28m is equal to 2 but after this last digit I get confused as to what the comma(,) stands for as well as the one after the roads_buffers.

If someone would explain to me in a straightforward manner what the comma(,) means I will receive a breakthrough in using r.mapcalc.

2

There are three components to that if() statement, separated by the two commas. Component 1 is a logical condition that returns True or False. Component 2 is what happens if the condition is True. Component three is what happens if the condition is False. Presumably, if the condition is True, the output pixel in 'noise' is assigned a value from the overlying pixel in 'roads_buffers'. If not, it is assigned the value null.

0

To add to obri_soil's answer, your statement more generally can be explained as:

"The layer 'noise' will be returned as 'road_buffers' if the 'landuse' layer has either of value 1 or 2. If landuse has any other values other than 1 or 2, you will get null/ no data"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.