[GRASS-user] Issue with r.mapcalc module

Vaclav Petras wenzeslaus at gmail.com
Thu Sep 6 19:51:39 PDT 2018


On Thu, Sep 6, 2018 at 7:55 AM Micha Silver <tsvibar at gmail.com> 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 listgrass-user at lists.osgeo.orghttps://lists.osgeo.org/mailman/listinfo/grass-user
>
>
> --
> Micha Silver
> Ben Gurion Univ.
> Sde Boker, Remote Sensing Lab
> +972-523-665918
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20180906/c6511986/attachment-0001.html>


More information about the grass-user mailing list