[GRASS-dev] Help needed Accessing Grass Modules through python

Bishwarup Banerjee bishwarup.banerjee at gmail.com
Tue Sep 15 01:09:23 EDT 2009


Hi Martin and Glynn,

Thank you very much for your response. But as I am newbie to this block, I
am not able to make out anything from your reply.
I suppose I am not able to clearly write the exact problem.

I have GRASS 6.3, Python 2.5 and working on Windows platform.

I need to access grass funtionalities from within my python program.
Now the question is How to do this?

On constant searching internet I found some material using g.parser, SWIG or
python libs. But I am not sure how to proceed with this.
Or how to configure these, so that I can use them.

It will be very helpful to me if you can step by step tell me how to go
ahead.
Thank you once again.

With Regards,
Bishwarup




On Mon, Sep 14, 2009 at 8:38 PM, Glynn Clements <glynn at gclements.plus.com>wrote:

>
> 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>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-dev/attachments/20090915/0b256d92/attachment.html


More information about the grass-dev mailing list