[GRASS-user] python interface

David Finlayson david.p.finlayson at gmail.com
Wed May 17 14:05:06 EDT 2006


I've used Python extensively with GRASS. As Jachym said, the os module
provides methods for calling external programs and retrieving their
output. I've found that it is easiest to launch your python scripts
from within a grass shell, that simplifies the environment variable
issues (same with Bash scripts).

For simple batch processing I prefer to use Bash and standard UNIX
tools (grep, cut, awk, etc) since your scripts will be more portable
between GRASS installations. However, there are times when you need
more power than bash provides and it is nice to have a full featured
scripting language like Python (or Perl) to do the heavy lifting.

Unfortunately, Python doesn't have a SWIG interface yet to the GRASS
API, so it cannot interface with GRASS at a more atomic level.
Currently, you can only do that with C. I think once, the C API
settles down I will try my hand at creating a SWIG interface to GRASS.
My vision is to have a simplified object model that would allow
non-experts to program cool tools for GRASS.

On 5/17/06, Jachym Cepicky <jachym.cepicky at centrum.cz> wrote:
> Hallo,
> plans are, but no time - could you spare some time? Perl should be
> implemented - python should not be much more comlicated.
>
> I'm just calling GRASS's modules over os.system or os.popen in my set of
> scripts (comming soon)...
>
> jachym
>
> On Wed, May 17, 2006 at 07:03:01PM +1200, Joel Pitt wrote:
> > Hi there,
> >
> > I was wondering if there are any plans to incorporate the python swig
> > interface into  current GRASS cvs (
> > http://gnowledge.org/pipermail/free-gis/2006-March/000075.html )?
> >
> > Also if any body has had any experience with using python with GRASS,
> > either using the mentioned swig interface or just as a scripting tool
> > I'd love to hear their experience/tips.
> >
> > Cheers,
> > Joel
> >
> > --
> > "Wish not to seem, but to be, the best."
> >                -- Aeschylus
> >
> > _______________________________________________
> > grassuser mailing list
> > grassuser at grass.itc.it
> > http://grass.itc.it/mailman/listinfo/grassuser
>
> --
> Jachym Cepicky
> e-mail: jachym.cepicky at centrum.cz
> URL: http://les-ejk.cz
> GPG: http://les-ejk.cz/gnupg_public_key/jachym_cepicky-gpg_public_key.asc
> -----------------------------------------
> OFFICE:
> GDF-Hannover
> Mengendamm 16d
> 30177 Hannover
> Germany
> e-mail: cepicky at gdf-hannover.de
> URL:    http://gdf-hannover.de
> Tel.:   +49 511-39088507
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (GNU/Linux)
>
> iD8DBQFEa01xyKt0uAjU4I8RAjc4AKCNl+T9yEVfpb4it10dgzuP64ZV5QCdE6ub
> zVQq+EfUJ5todIaL7/vlK8w=
> =0A6l
> -----END PGP SIGNATURE-----
>
>
> _______________________________________________
> grassuser mailing list
> grassuser at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grassuser
>
>
>


-- 
David Finlayson




More information about the grass-user mailing list