Skip to content
Prev 4505 / 29559 Next

read GRASS6 from outside

On Thu, 13 Nov 2008, Patrick Giraudoux wrote:

            
Patrick,

Could you explain why not? I can launch it, and I know others can, at 
least by:

Plugins -> GRASS -> Open GRASS Tools -> shell

and typing the full path to Rgui.exe at the shell prompt, for me:

$ "C:/Program Files/R/R-2.8.0/bin/Rgui.exe"

You may need to set the path to R_LIBS in user environment variables, or 
to add it to the command line in the GRASS shell prompt, or use 
.libPaths() within R, but beyond that, things should work, including file 
transfer etc.

The startup message in the current release does say "GRASS not running" 
because QGIS does not set the GRASS_VERSION or LOCATION_NAME environment 
variables, but does set GISRC - I'll try to fix that.

Doing getwd() in R will show that R is in the QGIS MSYS home directory for 
the user. This of course places R "on top" in standard spgrass6 fashion, 
but QGIS can be used at the same time. Work is progressing to embed R 
within QGIS, see:

http://www.ftools.ca/manageR.html

but until this is up and easily installable, going through the GRASS shell 
seems to work. Note that when you do system() from R, QGIS expects all 
executables to have the .exe extension added:

system("g.list rast") # fails
system("g.list.exe rast") # succeeds

Hope this helps,

Roger

PS. Note that the QGIS MSYS GRASS shell does history, so it logs the 
command to start R, which you retrieve with the up arrow in the usual way 
- the only editing needed is when you upgrade R.
PPS. In desperation, use v.(in/out).ogr and r.(in/out).gdal matched with 
read(GDAL/OGR) and write(GDAL/OGR) in rgdal, but watch which directory 
they land in.