Jenny Turner wrote:
I need to use this expression output=@input (input has labels and I want to
export them so i need to do this). How can I do this in grass.mapcalc in
Python? Does it accept @?
grass.mapcalc() is just a wrapper around r.mapcalc, so it supports
whatever r.mapcalc supports.
This:
grass.mapcalc('output = @input')
will work, but you wouldn't normally hard-code map names in a script.
grass.mapcalc() uses Python's string.Template class to simplify using
variables in expressions. This:
grass.mapcalc('$output = @$input', output = 'output', input = 'input')
is equivalent to the previous expression, but you can easily replace
the hard-coded names with variables, e.g.:
grass.mapcalc('$output = @$input', output = output, input = input)
Passing parameters which aren't used in the string is harmless, so you
can use Python's ** syntax to pass a dictionary of parameters, e.g.
the options dictionary obtained from grass.parser():
grass.mapcalc('$output = @$input', **options)
The values of the output= and input= options will be substituted into
the expression.
--
Glynn Clements gl...@gclements.plus.com
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user