initGRASS {spgrass6}R Documentation

Initiate GRASS session

Description

Run GRASS interface in an R session not started within GRASS. The function initializes environment variables used by GRASS, the .gisrc used by GRASS for further environment variables, and a temporary location.

Usage

initGRASS(gisBase, home, SG, gisDbase, location, mapset, override = FALSE, use_g.dirseps.exe = TRUE)

Arguments

gisBase The directory path to GRASS binaries and libraries
home The directory in which to create the .gisrc file; defaults to $HOME on Unix systems and to USERPROFILE on Windows systems; can usually be set to tempdir()
SG An optional SpatialGrid object to define the DEFAULT_WIND of the temporary location
gisDbase if missing, tempdir() will be used; GRASS GISDBASE directory for the working session
location if missing, basename(tempfile()) will be used; GRASS location directory for the working session
mapset if missing, basename(tempfile()) will be used; GRASS mapset directory for the working session
override default FALSE, set to TRUE if accidental trashing of GRASS .gisrc files and locations is not a problem
use_g.dirseps.exe default TRUE; when TRUE appears to work for WinGRASS Native binaries, when FALSE for QGIS GRASS binaries; ignored on other platforms.

Details

The function establishes an out-of-GRASS working environment providing GRASS commands with the environment variable support required, and may also provide a temporary location for use until the end of the running R session if the home argument is set to tempdir(), and the gisDbase argument is not given. Running gmeta6 shows where the location is, should it be desired to archive it before leaving R.

Value

The function runs gmeta6 before returning the current values of the running GRASS session that it provides.

Note

If any package command fails with a UTF-8 error from the XML package, try using setXMLencoding to work around the problem that GRASS modules declare –interface-description output as UTF-8 without ensuring that it is (French is of 6.4.0 RC5 latin1).

Author(s)

Roger S. Bivand, e-mail: Roger.Bivand@nhh.no

See Also

gmeta6

Examples

## Not run: 
initGRASS("/usr/local/grass-6.4.0", home=tempdir())
initGRASS("C:/GRASS", home=tempdir())
## End(Not run)

[Package spgrass6 version 0.6-14 Index]