[GRASS-dev] Plan to build Package to use GRASS from R
Glynn Clements
glynn at gclements.plus.com
Wed Feb 27 13:22:22 EST 2008
Rainer M Krug wrote:
> Sorry for crossposting, but I think this can be of interest for GRASS and R
> users.
>
> I am planning to write a package to make the use of GRASS from R easier. The
> idea is to wrap the system call to execute the GRASS command into an R
> command of the same name.
> e.g:
> r.to.vect <- function(..., intern=TRUE, ignore.stderr=FALSE)
> {
> comm <- paste( "r.to.vect ", ..., sep="" )
> print(comm)
> system( comm, intern=intern, ignore.stderr=ignore.stderr )
> }
>
> My questions are:
>
> 1) Is this a good way of doing it, or is giving a named list to the function
> more usefull?
If R provides a way to pass individual arguments (argc/argv), use that
instead of contructing a shell command as a string. Otherwise, you are
likely to run into problems with shell metacharacters in argument
values.
> 2) Is there a way to obtain easily all commands from GRASS and the
> parameters possible and required?
You can obtain a list of commands by enumerating the $GISBASE/bin and
$GISBASE/scripts directories. Nearly all commands support the
--interface-description switch, which outputs details of all of the
options in XML. There are several other switches which output the same
information in different formats; see the g.parser manpage for
details.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list