initGRASS in throwaway locations, to use GRASS modules on R objects without the need to define and populate a location. The function initializes environment variables used by GRASS, the .gisrc used by GRASS for further environment variables, and a temporary location. The locking functions are used internally, but are exposed for experienced R/GRASS scripters needing to use the GRASS module g.mapset through initGRASS in an existing GRASS location. In particular, g.mapset may leave a .gislock file in the current MAPSET, so it may be important to call unlink_.gislock to clean up before quitting the R session.
initGRASS(gisBase, home, SG, gisDbase, location, mapset, override = FALSE, use_g.dirseps.exe = TRUE, pid)
get.GIS_LOCK()
set.GIS_LOCK(pid)
unset.GIS_LOCK()
unlink_.gislock()$HOME on Unix systems and to USERPROFILE on Windows systems; can usually be set to tempdir()SpatialGrid object to define the DEFAULT_WIND of the temporary locationtempdir() will be used; GRASS GISDBASE directory for the working sessionbasename(tempfile()) will be used; GRASS location directory for the working sessionbasename(tempfile()) will be used; GRASS mapset directory for the working sessionas.integer(round(runif(1, 1, 1000))), integer used to identify GIS_LOCK; the value here is arbitrary, but probably should be set correctlygmeta before returning the current values of the running GRASS session that it provides.
home argument is set to tempdir(), and the gisDbase argument is not given. Running gmeta shows where the location is, should it be desired to archive it before leaving R.
gmeta## Not run:
# initGRASS("/usr/bin/grass-6.4.4", home=tempdir())
# initGRASS("C:/GRASS", home=tempdir())
# ## End(Not run)
Run the code above in your browser using DataLab