[GRASS-user] usage of r.mapcalc in python script

Markus Metz markus.metz.giswork at googlemail.com
Tue Dec 21 07:09:39 EST 2010


Margherita Di Leo wrote:
> Hi All,
>
> please any python programmer could explain me the correct use of r.mapcalc
> in this case.
> In my python script I have a formula like this:
>
> n = 0.016 * (resolution ** 0.46)
>
> (resolution is the cellsize of the input map).
> and I have to calculate a map with:
>
> grass.mapcalc("mti = log((exp($rast1 , n)) / $rast2)", rast1 =
> 'r_accumulation', rast2 = 'r_slope')
>

Try
grass.mapcalc("mti = log((exp($rast1 , $n)) / $rast2)", rast1 =
'r_accumulation', rast2 = 'r_slope', n = n)

Markus M

> but since n is not a map, i get the error:
>
> Invalid map <n>
> Parse error
> ERROR: An error occurred while running r.mapcalc
>
> How can I use the 'n' in r.mapcalc?
>
> Thank you in advance,
>
> Margherita
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
>


More information about the grass-user mailing list