error initGRASS - rgrass7

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

error initGRASS - rgrass7

Veronica Andreo
Hi,

I'm trying to run GRASS from R using:

library(rgrass7)
initGRASS(gisBase="/home/veroandreo/software/grass-7.0.svn",
          home=tempdir(), gisDbase="/home/veroandreo/grassdata",
          location="latlong_wgs84", mapset="clorofila", override=TRUE)

but I get the following error:  

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

Am I lacking something or is the function broken?? How should I use it??
Any help is appretiated :)

Thanks much in advance,
Vero


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

Re: error initGRASS - rgrass7

RKrug
Hi Veronica,

Veronica Andreo <[hidden email]> writes:

> Hi,
>
> I'm trying to run GRASS from R using:
>
> library(rgrass7)
> initGRASS(gisBase="/home/veroandreo/software/grass-7.0.svn",
>           home=tempdir(), gisDbase="/home/veroandreo/grassdata",
>           location="latlong_wgs84", mapset="clorofila", override=TRUE)

I assume you use Linux.

>
> but I get the following error:
>
> sh: g.gisenv: command not foundsh: g.gisenv: command not foundsh:
> g.gisenv: command not foundsh: g.gisenv: command not foundsh:
> g.gisenv: command not foundsh: g.version: command not foundError in
> system(paste("g.version", get("addEXE", envir = .GRASS_CACHE),  :
>   error in running command
>
>
> Am I lacking something or is the function broken?? How should I use it??
The easiest way of using R and GRASS GIS together, is starting GRASS GIS
and then in starting R in GRASS. This way, initGRASS() is not needed
anymore as the environment is already set up.

Are you sure that you gisBase is correct? Does GRASS work if you start
it?

Cheers,

Rainer

>
> Any help is appretiated :)
>
>
> Thanks much in advance,
>
> Vero
> _______________________________________________
> grass-stats mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/grass-stats
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

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

email:      [hidden email]

Skype:      RMkrug

PGP: 0x0F52F982

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats

signature.asc (490 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: error initGRASS - rgrass7

Markus Neteler
On Wed, Jul 22, 2015 at 3:11 PM, Rainer M Krug <[hidden email]> wrote:

> Hi Veronica,
>
> Veronica Andreo <[hidden email]> writes:
>
>> Hi,
>>
>> I'm trying to run GRASS from R using:
>>
>> library(rgrass7)
>> initGRASS(gisBase="/home/veroandreo/software/grass-7.0.svn",
>>           home=tempdir(), gisDbase="/home/veroandreo/grassdata",
>>           location="latlong_wgs84", mapset="clorofila", override=TRUE)
>
> I assume you use Linux.
>
>>
>> but I get the following error:
>>
>> sh: g.gisenv: command not foundsh: g.gisenv: command not foundsh:
>> g.gisenv: command not foundsh: g.gisenv: command not foundsh:
>> g.gisenv: command not foundsh: g.version: command not foundError in
>> system(paste("g.version", get("addEXE", envir = .GRASS_CACHE),  :
>>   error in running command
>>
>>
>> Am I lacking something or is the function broken?? How should I use it??
>
> The easiest way of using R and GRASS GIS together, is starting GRASS GIS
> and then in starting R in GRASS. This way, initGRASS() is not needed
> anymore as the environment is already set up.

We (especially Veronica) worked during the recent Community Sprint on
the Wiki pages

http://grasswiki.osgeo.org/wiki/R_statistics

to improve it, move out subchapters into separate pages etc.
The scope is to explain both directions which used to work with spgrass6.

Best
Markus

> Are you sure that you gisBase is correct? Does GRASS work if you start
> it?
>
> Cheers,
>
> Rainer
>
>>
>> Any help is appretiated :)
>>
>>
>> Thanks much in advance,
>>
>> Vero
>> _______________________________________________
>> grass-stats mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/grass-stats
>
> --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Stellenbosch University
> South Africa
>
> Tel :       +33 - (0)9 53 10 27 44
> Cell:       +33 - (0)6 85 62 59 98
> Fax :       +33 - (0)9 58 10 27 44
>
> Fax (D):    +49 - (0)3 21 21 25 22 44
>
> email:      [hidden email]
>
> Skype:      RMkrug
>
> PGP: 0x0F52F982
>
> _______________________________________________
> 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: error initGRASS - rgrass7

RKrug
Markus Neteler <[hidden email]> writes:

> On Wed, Jul 22, 2015 at 3:11 PM, Rainer M Krug <[hidden email]> wrote:
>> Hi Veronica,
>>
>> Veronica Andreo <[hidden email]> writes:
>>
>>> Hi,
>>>
>>> I'm trying to run GRASS from R using:
>>>
>>> library(rgrass7)
>>> initGRASS(gisBase="/home/veroandreo/software/grass-7.0.svn",
>>>           home=tempdir(), gisDbase="/home/veroandreo/grassdata",
>>>           location="latlong_wgs84", mapset="clorofila", override=TRUE)
>>
>> I assume you use Linux.
>>
>>>
>>> but I get the following error:
>>>
>>> sh: g.gisenv: command not foundsh: g.gisenv: command not foundsh:
>>> g.gisenv: command not foundsh: g.gisenv: command not foundsh:
>>> g.gisenv: command not foundsh: g.version: command not foundError in
>>> system(paste("g.version", get("addEXE", envir = .GRASS_CACHE),  :
>>>   error in running command
>>>
>>>
>>> Am I lacking something or is the function broken?? How should I use it??
>>
>> The easiest way of using R and GRASS GIS together, is starting GRASS GIS
>> and then in starting R in GRASS. This way, initGRASS() is not needed
>> anymore as the environment is already set up.
>
Hi

> We (especially Veronica) worked during the recent Community Sprint on
> the Wiki pages
>
> http://grasswiki.osgeo.org/wiki/R_statistics
>
> to improve it, move out subchapters into separate pages etc.

I think this is a brilliant idea.

I just looked at the example (GRASS GIS 7 in R), and it seems you are
specifying the wrong gisBase argument.

I get the same error in this case. If I specify the correct one, in my
case "/usr/local/Cellar/grass-70/7.0.0/grass-7.0.0" which looks as
follow (I highlighted the important directories, as far as I know):

,----
| 09:42:39 (master) /usr/local/Cellar/grass-70/7.0.0/grass-7.0.0$ ls -l
| total 240
| -rw-r--r--    1 rainerkrug  admin  15589 Jul 22 14:54 AUTHORS
| -rw-r--r--    1 rainerkrug  admin   1136 Jul 22 14:54 CHANGES
| -rw-r--r--    1 rainerkrug  admin   1458 Jul 22 14:54 COPYING
| -rw-r--r--    1 rainerkrug  admin  17987 Jul 22 14:54 GPL.TXT
| -rw-r--r--    1 rainerkrug  admin   7633 Jul 22 14:54 REQUIREMENTS.html
| drwxr-xr-x  373 rainerkrug  admin  12682 Jul 22 14:54 bin   <<<<<<<<<<<<<<<<<<<<<<<<
| -rwxr-xr-x    1 rainerkrug  admin  30466 Jul 22 14:54 config.status
| -rw-r--r--    1 rainerkrug  admin   3556 Jul 22 14:54 contributors.csv
| -rw-r--r--    1 rainerkrug  admin   1672 Jul 22 14:54 contributors_extra.csv
| drwxr-xr-x    4 rainerkrug  admin    136 Jul 22 14:54 demolocation
| drwxr-xr-x    4 rainerkrug  admin    136 Jul 22 14:52 docs
| drwxr-xr-x    3 rainerkrug  admin    102 Jul 22 14:52 driver
| drwxr-xr-x   28 rainerkrug  admin    952 Jul 22 14:54 etc
| drwxr-xr-x   25 rainerkrug  admin    850 Jul 22 14:52 fonts
| lrwxr-xr-x    1 rainerkrug  admin     14 Jul 22 14:55 grass70.sh -> ../bin/grass70
| drwxr-xr-x    7 rainerkrug  admin    238 Jul 22 14:54 gui
| drwxr-xr-x    4 rainerkrug  admin    136 Jul 22 14:52 include
| drwxr-xr-x  105 rainerkrug  admin   3570 Jul 22 14:54 lib   <<<<<<<<<<<<<<<<<<<<<<<<
| drwxr-xr-x   24 rainerkrug  admin    816 Jul 22 14:54 locale
| drwxr-xr-x  125 rainerkrug  admin   4250 Jul 22 14:54 scripts
| drwxr-xr-x    4 rainerkrug  admin    136 Jul 22 14:54 share
| drwxr-xr-x    9 rainerkrug  admin    306 Jul 22 14:52 tools
| -rw-r--r--    1 rainerkrug  admin  12668 Jul 22 14:54 translation_status.json
| -rw-r--r--    1 rainerkrug  admin   4111 Jul 22 14:54 translators.csv
`----

it works without any problems (Mac OSX Yosemite).

,----
| > sessionInfo()
| R version 3.2.1 (2015-06-18)
| Platform: x86_64-apple-darwin14.4.0 (64-bit)
| Running under: OS X 10.10.4 (Yosemite)
|
| 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-0 XML_3.98-1.3  sp_1.1-1
|
| loaded via a namespace (and not attached):
| [1] tools_3.2.1     grid_3.2.1      lattice_0.20-31
| > version
|                _
| platform       x86_64-apple-darwin14.4.0
| arch           x86_64
| os             darwin14.4.0
| system         x86_64, darwin14.4.0
| status
| major          3
| minor          2.1
| year           2015
| month          06
| day            18
| svn rev        68531
| language       R
| version.string R version 3.2.1 (2015-06-18)
| nickname       World-Famous Astronaut
| >
`----

Hope this helps.

Rainer

> The scope is to explain both directions which used to work with spgrass6.
>
> Best
> Markus
>
>> Are you sure that you gisBase is correct? Does GRASS work if you start
>> it?
>>
>> Cheers,
>>
>> Rainer
>>
>>>
>>> Any help is appretiated :)
>>>
>>>
>>> Thanks much in advance,
>>>
>>> Vero
>>> _______________________________________________
>>> grass-stats mailing list
>>> [hidden email]
>>> http://lists.osgeo.org/mailman/listinfo/grass-stats
>>
>> --
>> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
>>
>> Centre of Excellence for Invasion Biology
>> Stellenbosch University
>> South Africa
>>
>> Tel :       +33 - (0)9 53 10 27 44
>> Cell:       +33 - (0)6 85 62 59 98
>> Fax :       +33 - (0)9 58 10 27 44
>>
>> Fax (D):    +49 - (0)3 21 21 25 22 44
>>
>> email:      [hidden email]
>>
>> Skype:      RMkrug
>>
>> PGP: 0x0F52F982
>>
>> _______________________________________________
>> grass-stats mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/grass-stats
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

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

email:      [hidden email]

Skype:      RMkrug

PGP: 0x0F52F982

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats

signature.asc (490 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: error initGRASS - rgrass7

Markus Neteler
Hi,

On Fri, Jul 24, 2015 at 9:47 AM, Rainer M Krug <[hidden email]> wrote:

> Markus Neteler <[hidden email]> writes:
>
>> On Wed, Jul 22, 2015 at 3:11 PM, Rainer M Krug <[hidden email]> wrote:
>>> Hi Veronica,
>>>
>>> Veronica Andreo <[hidden email]> writes:
>>>
>>>> Hi,
>>>>
>>>> I'm trying to run GRASS from R using:
>>>>
>>>> library(rgrass7)
>>>> initGRASS(gisBase="/home/veroandreo/software/grass-7.0.svn",
>>>>           home=tempdir(), gisDbase="/home/veroandreo/grassdata",
>>>>           location="latlong_wgs84", mapset="clorofila", override=TRUE)
>>>
>>> I assume you use Linux.
>>>
>>>>
>>>> but I get the following error:
>>>>
>>>> sh: g.gisenv: command not found

so, I found the trick:

In the first place, find out the path to the GRASS GIS library. This
can be easily done with the following command (still outside of R; or
through a system() call inside of R):

 grass70 --config path


It may report something like:
 /home/veroandreo/software/grass-7.0.svn/dist.x86_64-unknown-linux-gnu

This path must be used then:

library(rgrass7)

# initialisation and the use of North Carolina sample dataset
initGRASS(gisBase =
"/home/veroandreo/software/grass-7.0.svn/dist.x86_64-unknown-linux-gnu",
home = tempdir(),
          gisDbase = "/home/veroandreo/grassdata/",
          location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",
          override = TRUE)
...

and it works fine.

I have updated the Wiki page accordingly:
http://grasswiki.osgeo.org/wiki/R_statistics/rgrass7#GRASS_within_R

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

Re: error initGRASS - rgrass7

Veronica Andreo
Hi Markus, Rainer, all,

Thanks a lot for the help! :) 

I've now completed the update of: 

Cheers, 
Vero

ps: I insist it would be awesome to also have support to read/write spatio-temporal raster datasets (strds) in rgrass7 :)

2015-07-31 11:56 GMT-03:00 Markus Neteler <[hidden email]>:
Hi,

On Fri, Jul 24, 2015 at 9:47 AM, Rainer M Krug <[hidden email]> wrote:
> Markus Neteler <[hidden email]> writes:
>
>> On Wed, Jul 22, 2015 at 3:11 PM, Rainer M Krug <[hidden email]> wrote:
>>> Hi Veronica,
>>>
>>> Veronica Andreo <[hidden email]> writes:
>>>
>>>> Hi,
>>>>
>>>> I'm trying to run GRASS from R using:
>>>>
>>>> library(rgrass7)
>>>> initGRASS(gisBase="/home/veroandreo/software/grass-7.0.svn",
>>>>           home=tempdir(), gisDbase="/home/veroandreo/grassdata",
>>>>           location="latlong_wgs84", mapset="clorofila", override=TRUE)
>>>
>>> I assume you use Linux.
>>>
>>>>
>>>> but I get the following error:
>>>>
>>>> sh: g.gisenv: command not found

so, I found the trick:

In the first place, find out the path to the GRASS GIS library. This
can be easily done with the following command (still outside of R; or
through a system() call inside of R):

 grass70 --config path


It may report something like:
 /home/veroandreo/software/grass-7.0.svn/dist.x86_64-unknown-linux-gnu

This path must be used then:

library(rgrass7)

# initialisation and the use of North Carolina sample dataset
initGRASS(gisBase =
"/home/veroandreo/software/grass-7.0.svn/dist.x86_64-unknown-linux-gnu",
home = tempdir(),
          gisDbase = "/home/veroandreo/grassdata/",
          location = "nc_spm_08_grass7", mapset = "user1", SG="elevation",
          override = TRUE)
...

and it works fine.

I have updated the Wiki page accordingly:
http://grasswiki.osgeo.org/wiki/R_statistics/rgrass7#GRASS_within_R

Cheers
Markus


_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats