[GRASS-user] r.mapcal sintax error
Markus Neteler
neteler at osgeo.org
Sat Apr 11 16:22:18 EDT 2009
On Sat, Apr 11, 2009 at 10:00 PM, Margherita Di Leo <diregola at gmail.com> wrote:
> Hi all,
>
> i'm in trouble using r.mapcalc in Grass 6.5 svn
>
> In order to replace in a raster map (basin_10m) the values 24,26 with 28, i
> use the following cmd line:
>
> r.mapcalc 'basin_10m_2=if(basin_10m==24),28'
> r.mapcalc 'basin_10m_2=if(basin_10m==26),28'
You need to set the braces correctly (personally, I use
double quotes to be able to use shell variables). Also
better define the "else" part:
if(condition, then, else)
so
r.mapcalc "basin_10m_2=if(basin_10m==24, 28, null())"
r.mapcalc "basin_10m_3=if(basin_10m==26, 28, null())"
Note that I changed the second map name to _3 otherwise
it would overwrite the first.
You can also combine conditions, e.g.:
if(condition1 && condition2, then, else)
cheers
Markus
More information about the grass-user
mailing list