Discussion:
[GRASS-user] Running GRASS within R (Rstudio) on MacOS
Johannes Radinger
2017-09-07 08:04:55 UTC
Permalink
Hi,

I try to run GRASS73 within R (actually R-studio) using the rgrass7 library
on MacOS 10.12.6. I followed the instructions stated in the wiki (
https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7), however some of the
commands were not working for me. For instance, "grass70 --config path"
(also with grass73 etc) does not work here, however I found the path to the
application which is: /Applications/GRASS-7.3.app; i.e. using
"open /Applications/GRASS-7.3.app" opens my grass installation.

So I tried to initialize GRASS (North Carolina location - PERMANENT) from
within R using the initGRASS() command:

initGRASS(gisBase = "/Applications/GRASS-7.3.app", home = tempdir(),
gisDbase = "/Users/Johannes_Radinger/Documents/GRASS-GIS/",
location = "nc_spm_08_grass7", mapset = "PERMANENT",
SG="elevation",
override=TRUE)

However I get following error(s):
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.version: command not found
Error in system(paste("g.version", get("addEXE", envir = .GRASS_CACHE), :
error in running command

So what I am doing wrong? Do I miss some arguments in my command or is this
related to my Mac environment? Any suggestion I should try to solve that
problem?

Thanks and best regards,
Johannes
Johannes Radinger
2017-09-07 11:19:33 UTC
Permalink
Hi Rainer,

I used following commands and got following errors and output (using
Rstudio). I also included now the output from sessionInfo() after loading
library("rgrass7")
Loading required package: sp
Loading required package: XML
GRASS GIS interface loaded with GRASS version: (GRASS not running)
Warning message:
package ‘XML’ was built under R version 3.4.1
#https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7
sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS:
/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK:
/Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] rgrass7_0.1-9 XML_3.98-1.9 sp_1.2-4

loaded via a namespace (and not attached):
[1] minqa_1.2.4 MASS_7.3-47 compiler_3.4.0 Matrix_1.2-10
tools_3.4.0 Rcpp_0.12.11 splines_3.4.0
[8] nlme_3.1-131 grid_3.4.0 nloptr_1.0.4 lme4_1.1-13
lattice_0.20-35
# initialisation and the use of North Carolina sample dataset
initGRASS(gisBase = "/Applications/GRASS-7.3.app", home = tempdir(),
+ gisDbase = "/Users/Johannes_Radinger/Documents/GRASS-GIS/",
+ location = "nc_spm_08_grass7", mapset = "PERMANENT",
SG="elevation",
+ override=TRUE)
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.version: command not found
Error in system(paste("g.version", get("addEXE", envir = .GRASS_CACHE), :
error in running command

######

cheers,
Johannes
Hi
How did you run these commands from R, which error did you get?
Could you provide a transcript of your errors?
Rainer
Hi,
I try to run GRASS73 within R (actually R-studio) using the rgrass7
library on MacOS 10.12.6. I followed the instructions stated in the wiki (
https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7), however some of
the commands were not working for me. For instance, "grass70 --config path"
(also with grass73 etc) does not work here, however I found the path to the
application which is: /Applications/GRASS-7.3.app; i.e. using
"open /Applications/GRASS-7.3.app" opens my grass installation.
So I tried to initialize GRASS (North Carolina location - PERMANENT) from
initGRASS(gisBase = "/Applications/GRASS-7.3.app", home = tempdir(),
gisDbase = "/Users/Johannes_Radinger/Documents/GRASS-GIS/",
location = "nc_spm_08_grass7", mapset = "PERMANENT",
SG="elevation",
override=TRUE)
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.version: command not found
error in running command
So what I am doing wrong? Do I miss some arguments in my command or is
this related to my Mac environment? Any suggestion I should try to solve
that problem?
Thanks and best regards,
Johannes
_______________________________________________
grass-user mailing list
https://lists.osgeo.org/mailman/listinfo/grass-user
Rainer Krug
2017-09-07 11:31:27 UTC
Permalink
Hi

The problem is the gisBase. it is the directory with the e.g. lib, bin directories. I am not using the GRASS App but installed from Home-brew, so I can’t help you there. Just look for general intro on how to use Grass in R on Mac.

Cheers,

Rainer
Post by Johannes Radinger
Hi Rainer,
library("rgrass7")
Loading required package: sp
Loading required package: XML
GRASS GIS interface loaded with GRASS version: (GRASS not running)
package ‘XML’ was built under R version 3.4.1
#https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7 <https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7>
sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
[1] stats graphics grDevices utils datasets methods base
[1] rgrass7_0.1-9 XML_3.98-1.9 sp_1.2-4
[1] minqa_1.2.4 MASS_7.3-47 compiler_3.4.0 Matrix_1.2-10 tools_3.4.0 Rcpp_0.12.11 splines_3.4.0
[8] nlme_3.1-131 grid_3.4.0 nloptr_1.0.4 lme4_1.1-13 lattice_0.20-35
# initialisation and the use of North Carolina sample dataset
initGRASS(gisBase = "/Applications/GRASS-7.3.app", home = tempdir(),
+ gisDbase = "/Users/Johannes_Radinger/Documents/GRASS-GIS/",
+ location = "nc_spm_08_grass7", mapset = "PERMANENT", SG="elevation",
+ override=TRUE)
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.version: command not found
error in running command
######
cheers,
Johannes
Hi
How did you run these commands from R, which error did you get?
Could you provide a transcript of your errors?
Rainer
Hi,
I try to run GRASS73 within R (actually R-studio) using the rgrass7 library on MacOS 10.12.6. I followed the instructions stated in the wiki (https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7 <https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7>), however some of the commands were not working for me. For instance, "grass70 --config path" (also with grass73 etc) does not work here, however I found the path to the application which is: /Applications/GRASS-7.3.app; i.e. using "open /Applications/GRASS-7.3.app" opens my grass installation.
initGRASS(gisBase = "/Applications/GRASS-7.3.app", home = tempdir(),
gisDbase = "/Users/Johannes_Radinger/Documents/GRASS-GIS/",
location = "nc_spm_08_grass7", mapset = "PERMANENT", SG="elevation",
override=TRUE)
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.gisenv: command not found
sh: g.version: command not found
error in running command
So what I am doing wrong? Do I miss some arguments in my command or is this related to my Mac environment? Any suggestion I should try to solve that problem?
Thanks and best regards,
Johannes
_______________________________________________
grass-user mailing list
https://lists.osgeo.org/mailman/listinfo/grass-user <https://lists.osgeo.org/mailman/listinfo/grass-user>
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

University of ZÃŒrich

Cell: +41 (0)78 630 66 57

Fax (D): +49 - (0)3 21 21 25 22 44

email: ***@krugs.de

Skype: RMkrug

Loading...