[GRASS-user] Running GRASS within R (Rstudio) on MacOS

Rainer Krug Rainer at krugs.de
Thu Sep 7 04:31:27 PDT 2017


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



> On 7 Sep 2017, at 13:19, Johannes Radinger <johannesradinger at gmail.com> wrote:
> 
> Hi Rainer,
> 
> I used following commands and got following errors and output (using Rstudio). I also included now the output from sessionInfo() after loading "rgrass7":
> 
> > 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 <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
> 
> 
> On Thu, Sep 7, 2017 at 11:36 AM, Rainer Krug <rainer_krug at icloud.com <mailto:rainer_krug at icloud.com>> wrote:
> Hi
> 
> How did you run these commands from R, which error did you get?
> 
> Could you provide a transcript of your errors?
> 
> Rainer
> 
>> On 7 Sep 2017, at 10:04, Johannes Radinger <johannesradinger at gmail.com <mailto:johannesradinger at gmail.com>> wrote:
>> 
>> 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.
>> 
>> 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
>> 
>> _______________________________________________
>> grass-user mailing list
>> grass-user at lists.osgeo.org <mailto:grass-user at lists.osgeo.org>
>> 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:      Rainer at krugs.de

Skype:      RMkrug

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20170907/c76f6943/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20170907/c76f6943/attachment-0001.sig>


More information about the grass-user mailing list