initGRASS versus R in grass - WAS: [GRASS-stats] Error using GRASS from R

Rainer M Krug r.m.krug at gmail.com
Thu Jul 21 04:52:31 EDT 2011


2011/7/20 Roger Bivand <Roger.Bivand at nhh.no>

> On Wed, 20 Jul 2011, Tim Besser wrote:
>
>  Dear GRASS-community,
>>
>> I have a very strange problem. I wrote a script in R (2.10.1) for the
>> preparation of my datasets which works fine on my laptop (winxp). I do not
>> start my R session from GRASS but use GRASS through the initGRASS and
>> execGRASS commands. I use the "spgrass6" package and GRASS 6.4.1. As the
>> script would run for days on my old laptop I now got a remote desktop
>> connection to a much faster computer at the university (win7). However,
>> while cmds like r.reclass or r.in.gdal (execGRASS) work on that computer the
>> r.patch (execGRASS) cmd produces following error:
>>
>
> Do not start R in GRASS using initGRASS when you are using an exiting
> location - I will most likely remove this possibility at the next release as
> it confuses users


No - please don't. I am using it a lot, and it works very nicely (at least
(and only?) for me?). And it makes live so much easier for me - I am running
the simulations non-interactive on a cluster, and starting grass, which then
starts R was always a hassle.

What about adding a new option (errorOnExistingLocation=TRUE), which raises
an error when the location exists?

I assume that quite a few users are using R as a scripting language, and in
this case, and consequently is more logical to me to have R as the base,
which then initializes the grass environment when I need it, and not that I
have to decide before I start R, if I have to start R in grass.

I must admit, I am not to clear why it can be a problem when using initGRASS
for an existing location (I know you explained it already, but I must have
missed something).

I remember reading that somebody was putting all the gras environmental
variable initialization into .bash so that he/she can use grass from any
terminal - so just setting the variables should be enough, if one is careful
not to work in the same location from two different shells (i.e. grass
sessions).

So there are effectively two aspects of interfacing GRASS with R:

1) analysing spatial data which *is in R* with GRASS
2) analysing spatial data which *is in a GRASS database* with R

I am using a mix of 1 and 2: my data comes from R and (mainly) a GRASS
database, is processed in R and GRASS, and results are stored in the GRASS
database.

As the name of the location is determined in the parameter file (which is
loaded into the R session), to go back to R inside grass would make things
considerably more complex.

By the way - how is python handling the link to GRASS? As I never used
python, I have no idea how this works.

Hope I will be able to convince you to leave the possibility in spgrass6,

Cheers,

Rainer

 ...SNIP...

> Roger
>
>
>
>> execGRASS("r.patch", flags=c("z"), parameters=list(input="**
>> mangroves_1989_138_044_LR_**recl,mangroves_1989_138_045_**
>> UL_recl,mangroves_1989_138_**045_UR_recl", output="testomat"), intern=T)
>>
>> Error in system(cmd0, intern = TRUE) :
>>  Createprocess konnte 'C:\GRASS6~1.1\bin\RPATCH~1.**EXE
>> --interface-description' nicht ausführen
>> Fehler in parseGRASS(cmd) : r.patch not found
>>
>> I checked the GRASS directory and it is set right in the initGRASS
>> command.
>>
>> I hope you can help me with one. I have no clue what to do!
>>
>> Thanks in advance,
>>
>> Tim
>>
>> ______________________________**_________________
>> grass-stats mailing list
>> grass-stats at lists.osgeo.org
>> http://lists.osgeo.org/**mailman/listinfo/grass-stats<http://lists.osgeo.org/mailman/listinfo/grass-stats>
>>
>>
> --
> Roger Bivand
> Department of Economics, NHH Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; fax +47 55 95 95 43
> e-mail: Roger.Bivand at nhh.no
> _______________________________________________
> grass-stats mailing list
> grass-stats at lists.osgeo.org
> 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 (F):       +33 - (0)9 58 10 27 44

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-stats/attachments/20110721/efe22059/attachment.html


More information about the grass-stats mailing list