[GRASSLIST:2089] Re: programming interface to GRASS

Roger Bivand Roger.Bivand at nhh.no
Fri Jul 6 16:36:46 EDT 2001

On Fri, 6 Jul 2001, Robert Najlis wrote:

> Is there a way to run GRASS from within compiled code - such as
> Java,C/C++,Perl,Ruby,Python, etc.  At this point it seems that I could run
> a program from within the GRASS shell and interact with GRASS that way.
> However, I really want to use GRASS for its analytical abilities as part
> of a larger program, so I would like to have full control from that
> program, and not have to be within the GRASS shell environment.  I believe
> that ESRI has this capability through Microsoft COM objects. I would like
> this to be on a Unix machine though, so COM is out of the question.
One example you might consider looking at is the R/GRASS interface for
reading GRASS raster and sites files into R - a statistics programming
language and writing them back out again - the current release is on
http://cran.r-project.org -> Package sources -> Devel -> 
GRASS_0.1-7.tar.gz. Reading the C code may give you a prototype for
getting the raster layers across the interface for the libgis.a
functions. You could also look at libgrass at 
http://gdal.velocet.ca/projects/grass/ for the same kinds of things. From
there on, you will be using system() a lot to run the GRASS analysis
programs, they are stand-alone within the GRASS environment, which just
means having specific environment variables correctly set.


Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
and: Department of Geography and Regional Development, University of
Gdansk, al. Mar. J. Pilsudskiego 46, PL-81 378 Gdynia, Poland.

More information about the grass-user mailing list