On Thu, Sep 6, 2018 at 7:55 AM Micha Silver <[email protected]> wrote:

> You need quotes around the expression:
>
> On 06/09/2018 13:47, Vidura Dantanarayana wrote:
>
> Hi all,
> I need to create a raster file with the
> if(fuel_class==4,3,if(fuel_class==8,15)) expression. I used the following
> command but it result a parse error.
>
> r.mapcalc --overwrite expression=1hr_moisture =
> if(fuel_class==4,3,if(fuel_class==8,15))
>
> r.mapcalc --overwrite expression="1hr_moisture =
> if(fuel_class==4,3,if(fuel_class==8,15))"
>
> Also, what happens if feul_class is not 4 and not 8??
>


Good point.


>
> What could be the reason for the error?
>
>
Not sure, perhaps more info would be in the whole error message, but here
are some tips:

1. Check if the input raster map exists.
2. Do not start the raster map name with a number.
3. Use space after comma and around operators (best practice).

Here is the same expression but with the suggestions and null() for the
case Mica mentioned (note that I didn't actually tested that):

r.mapcalc --overwrite expression="moisture_1hr = if(fuel_class == 4, 3,
if(fuel_class == 8, 15, null()))"

Vaclav


> BR,
> Vidura Dantanarayana.
>
>
>
> _______________________________________________
> grass-user mailing 
> [email protected]https://lists.osgeo.org/mailman/listinfo/grass-user
>
>
> --
> Micha Silver
> Ben Gurion Univ.
> Sde Boker, Remote Sensing Lab
> +972-523-665918
>
> _______________________________________________
> grass-user mailing list
> [email protected]
> https://lists.osgeo.org/mailman/listinfo/grass-user
_______________________________________________
grass-user mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to