Adam Wilson wrote: > I use R and GRASS together and frequently switch back and forth to > accomplish tasks (this is the main reason I've stopped using Arc products - > it's difficult to interface with a powerful statistics program), so I wanted > to find a way to use GRASS easily within the EMACS - ESS environment (where > I do my R work). I found that this is as simple as starting an R process > (see http://ess.r-project.org/index.php?Section=home), then switching to > GRASS with a system() command and specifying the mapset. The send line > function still works the same as in R, so the functionality is very > similar. > > For example: > > 1. Open emacs and start R as described in the ess documentation > http://ess.r-project.org/index.php?Section=home > 2. run: system("grass63 > /media/Data/Work/grassdata/spearfish/PERMANENT") # or whatever grass > version and location/mapset you want to open. This can be the first line > of > your script. > 3. That's it, you now have an interactive GRASS session that you can send > lines of code using the ess interface. > 4. if you want to start a R process within GRASS, you can run "R" at the > grass prompt and you start a new nested R process, where you can load > library(spgrass6) and use all those powerful R functions
FWIW, I would suggest skipping the "grass63" startup altogether. I source the following script from my ~/.bash_profile (which is sourced by my ~/.xsession file, so the settings also apply to X programs): #export GISBASE=/opt/grass-7.0.svn export GISBASE=/usr/local/src/grass/svn/dist.i686-pc-linux-gnu export GRASS_GNUPLOT='gnuplot -persist' export GRASS_WIDTH=640 export GRASS_HEIGHT=480 export GRASS_HTML_BROWSER=firefox export GRASS_PAGER=cat export GRASS_WISH=wish export GRASS_PYTHON=python export GRASS_MESSAGE_FORMAT=silent export GRASS_TRUECOLOR=TRUE export GRASS_TRANSPARENT=TRUE export GRASS_PNG_AUTO_WRITE=TRUE export PATH="$GISBASE/bin:$GISBASE/scripts:$PATH" export LD_LIBRARY_PATH="$GISBASE/lib" export GRASS_LD_LIBRARY_PATH="$LD_LIBRARY_PATH" export PYTHONPATH="$GISBASE/etc/python:$PYTHONPATH" export MANPATH=$MANPATH:$GISBASE/man export GIS_LOCK=$$ export GRASS_VERSION="7.0.svn" tmp=/tmp/grass6-"`whoami`"-$GIS_LOCK export GISRC="$tmp/gisrc" mkdir "$tmp" cp ~/.grassrc6 "$GISRC" This means that I can run GRASS commands anywhere, e.g. using M-! from within XEmacs. You can use g.mapset to change database/location/mapset. It should also allow you to use other packages which normally only work "within GRASS". Starting a login shell ("bash --login", which sources ~/.bash_profile) will create a separate session with its own $GISRC file. Many of the environment variables are optional. The ones which really matter are GISBASE, GISRC, PATH and LD_LIBRARY_PATH. g.mapset requires GIS_LOCK to be set, but it doesn't matter to what. The others are only used by specific modules; see variables.html in the GRASS documentation for an extensive list. -- Glynn Clements <gl...@gclements.plus.com> _______________________________________________ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user