initGRASS() never stops running?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

initGRASS() never stops running?

Andrew Plowright
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.

Any help would be greatly appreciated. Thank you!

Andrew Plowright

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Reply | Threaded
Open this post in threaded view
|

Re: initGRASS() never stops running?

Roger Bivand
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: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: initGRASS() never stops running?

pvanbosgeo


On Sun, Feb 7, 2016 at 3:25 PM, Roger Bivand <[hidden email]> 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).

I am using Rstudio within GRASS without problems (on Ubuntu 14.04). No specific configuration required as far as I remember. Also on Windows I generally have no problem running Rstudio under GRASS (the latter installed using OSGeo4W), but there I had to define the path to Rstudio (https://pvanb.wordpress.com/2014/12/17/access-r-from-grass-gis-on-windows/)
 

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: <a href="tel:%2B47%2055%2095%2093%2055" value="+4755959355" target="_blank">+47 55 95 93 55; fax <a href="tel:%2B47%2055%2095%2091%2000" value="+4755959100" target="_blank">+47 55 95 91 00
e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats


_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Reply | Threaded
Open this post in threaded view
|

Re: initGRASS() never stops running?

Andrew Plowright
In reply to this post by Roger Bivand
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 <[hidden email]> 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: <a href="tel:%2B47%2055%2095%2093%2055" value="+4755959355" target="_blank">+47 55 95 93 55; fax <a href="tel:%2B47%2055%2095%2091%2000" value="+4755959100" target="_blank">+47 55 95 91 00
e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412


_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Reply | Threaded
Open this post in threaded view
|

Re: initGRASS() never stops running?

pvanbosgeo
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 <[hidden email]> 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 <[hidden email]> 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: <a href="tel:%2B47%2055%2095%2093%2055" value="+4755959355" target="_blank">+47 55 95 93 55; fax <a href="tel:%2B47%2055%2095%2091%2000" value="+4755959100" target="_blank">+47 55 95 91 00
e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412



_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Reply | Threaded
Open this post in threaded view
|

Re: initGRASS() never stops running?

Helmut Kudrnovsky
In reply to this post by pvanbosgeo
>I am using Rstudio within GRASS without problems (on Ubuntu 14.04). No specific configuration required as >far as I remember. Also on Windows I generally have no problem running Rstudio under GRASS (the latter >installed using OSGeo4W), but there I had to define the path to Rstudio (https://pvanb.wordpress.com
>/2014/12/17/access-r-from-grass-gis-on-windows/)

it shouldn't be needed anymore; some time ago I've added the path to R studio to OSGeo4W- and standalone winGRASS 7, see:

https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/mswindows/env.bat#L18
https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/mswindows/osgeo4w/env.bat.tmpl#L18
best regards
Helmut