[GRASS-stats] initGRASS() never stops running?

Paulo van Breugel p.vanbreugel at gmail.com
Sun Feb 7 10:17:15 PST 2016


Hi Andrew

The easiest way to get GRASS commands to run from within RStudio is:

1) Start GRASS
2) From the same command line start RStudio
3) in RStudio load the rgrass7 library: library(rgrass7)
4) Run your GRASS commands, e..g, execGRASS("g.region", flags="p")

Following these steps, there should be no need to run initGRASS(). Now,
there are user cases in which you may want to run GRASS commands from R
without first starting R from within a GRASS session, but from what you
write the steps above are probably more convenient.

For more details on both approaches, see
https://grasswiki.osgeo.org/wiki/R_statistics/rgrass7

Paulo




On Sun, Feb 7, 2016 at 6:56 PM, Andrew Plowright <plowright.andrew at gmail.com
> wrote:

> Hi Roger and Paulo,
>
> Thanks for your replies. Just to be specific, I'm trying to run GRASS from
> within RStudio, not the other way around. I noticed that the version of
> rgrass7 I was using was built under R v.3.2.3, so I updated that. However,
> even when trying to run initGRASS() from RGui, I run into the same problem
> (I'm not quite sure how to run things from the command line).
>
> When searching for solutions to this problem, I came across an old thread
> from this mailing list that said that initGRASS() was not necessary when
> GRASS was running. I launched GRASS, but still, when running loading the
> rgrass7 library from Rgui I get the message:
>
> > library(rgrass7)
> Loading required package: sp
> Loading required package: XML
> GRASS GIS interface loaded with GRASS version: (GRASS not running)
>
> I guess R and GRASS are really just not communicating?
>
> Andrew
>
> On Sun, Feb 7, 2016 at 6:25 AM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
>
>> On Sun, 7 Feb 2016, Andrew Plowright wrote:
>>
>> Hello,
>>>
>>> I recently subscribed to this mailing list since I was hoping to get a
>>> bit
>>> of help setting up the rgrass7 package. I do all my GIS work in R, and am
>>> very excited by the prospect of using GRASS functions through the R
>>> environment. Unfortunately, I haven't gotten very far since I don't seem
>>> to
>>> be able to use the initGRASS() function correctly! When I run:
>>>
>>> library(rgrass7)
>>> initGRASS("C:\\Program Files\\GRASS GIS 7.0.3", home=tempdir())
>>>
>>> ... R Studio simply runs forever. It does not give me an error message...
>>> it just keeps running until I force close the program. I am using R
>>> version
>>> 3.2.2, and have installed GRASS version 7.0.3, which is installed in
>>> "C:\Program Files\GRASS GIS 7.0.3" folder. GRASS GIS seems to be running
>>> perfectly fine on its own.
>>>
>>
>>
>> Rstudio is very likely running the system*() commands and the commands
>> setting environment variables in ways that interfere in your case. Start by
>> using R from the command line, then RGui, then find out how to debug
>> running functions in Rstudio and run initGRASS under the debugger to see at
>> which step contact gets lost.
>>
>> I believe that there are reports of success using Rstudio within GRASS
>> (in an existing GRASS location, starting Rstudio within GRASS).
>>
>> Does anyone have any experience? (I do not use Rstudio, so cannot tell -
>> under Linux it wants R built in a specific way that I don't want to be
>> forced to change to).
>>
>> Roger
>>
>>
>>> Any help would be greatly appreciated. Thank you!
>>>
>>> Andrew Plowright
>>>
>>>
>> --
>> Roger Bivand
>> Department of Economics, Norwegian School of Economics,
>> Helleveien 30, N-5045 Bergen, Norway.
>> voice: +47 55 95 93 55; fax +47 55 95 91 00
>> e-mail: Roger.Bivand at nhh.no
>> http://orcid.org/0000-0003-2392-6140
>> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
>> http://depsy.org/person/434412
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-stats/attachments/20160207/e012d7ff/attachment-0001.html>


More information about the grass-stats mailing list