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))
What could be the reason for the error?
BR,
Vidura Dantanarayana.
You need quotes around the expression:
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??
···
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))
What could be the reason for the error?
BR,
Vidura Dantanarayana.
_______________________________________________
grass-user mailing list
[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
[https://lists.osgeo.org/mailman/listinfo/grass-user](https://lists.osgeo.org/mailman/listinfo/grass-user)
--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
+972-523-665918
On Thu, Sep 6, 2018 at 7:55 AM Micha Silver <tsvibar@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:
-
Check if the input raster map exists.
-
Do not start the raster map name with a number.
-
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 list
[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
[https://lists.osgeo.org/mailman/listinfo/grass-user](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
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user