[GRASS-dev] Help needed Accessing Grass Modules through python
Glynn Clements
glynn at gclements.plus.com
Mon Sep 14 11:08:51 EDT 2009
Martin Landa wrote:
> > I am working on accessing grass functionalities through python, but I don't
> > know which way I should take to achieve this goal.
> >
> > I have SWIG WIN, GRASS 6.3, Python 2.5, Quantum GIS 0.11
> >
> > I want to call suppose "mapcalc" of grass from inside python.
> >
> > Whether this is possible, If yes then how. Whether it can be achieved
> > through g.parser, SWIG or through any other way.
>
> I would suggest to use Python scripting library from GRASS >= 6.4 [1].
> See raster.mapcalc().
The existing grass.mapcalc() function won't work in 6.4. That function
shouldn't have been backported from 7.0, as it requires the 7.0
version of r.mapcalc (which uses G_parser()).
It needs something like:
- if run_command('r.mapcalc', expression = e) != 0:
+ if write_command('r.mapcalc', stdin = e) != 0:
Either that, or use call(['r.mapcalc', expression]).
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list