[GRASS-dev] R and GRASS integration

Paulo van Breugel p.vanbreugel at gmail.com
Tue Jan 5 23:50:59 PST 2016


I by any stretch of imagination a developer, but I did use the 
combination of shell or pythons script with R, basically following the 
approach you described, having a python or shell script write a R script 
to a text file and run it. I think it can work well, and not that much 
harder to maintain. But I also would be very interested to learn how to 
do this better. I also would be interested to see the randomForest 
scripts you mentioned Steven, are you already sharing it somewhere?

As you mentioned, there are probably many people using / writing R 
scripts that interact with GRASS. For some it will be easier, or it may 
be more logical for them, to turn these into R packages rather than 
writing a GRASS addon. It would be nice if there would be some kind of 
repository where people share such code (github perhaps?). I am sure 
there are existing ones on e.g., github, so perhaps just a GRASS-wiki 
page listing existing repositories would be enough. I know there is 
https://grasswiki.osgeo.org/wiki/R_statistics, but I don't think there 
is an place on the GRASS website, wiki or trac to share/list R code? 
Would this be of interest to create such page (on the Wiki perhaps?).

Paulo


On 04-01-16 16:14, Steven Pawley wrote:
> Thank you Moritz,
>
> Yes I have also had difficulties with Rpy2 apart from on Linux. Also, Rpy2 is quite onerous in terms of effort required to integrate R scripts into Python. Your solution certainly works,  but as you mentioned it makes the R script harder to maintain. PypeR is another alternative and is straightforward to install and is simpler from a user perspective.
>
> I would also be interested in hearing opinions from 'true' developers who have much greater expertise than myself in this area.
>
> Kind regards,
>
> Steve
>
>> On Jan 4, 2016, at 2:31 AM, Moritz Lennert <mlennert at club.worldonline.be> wrote:
>>
>>> On 04/01/16 10:28, Moritz Lennert wrote:
>>>> On 03/01/16 23:54, Steven Pawley wrote:
>>>> Like many R-GRASS users, I have a collection of R scripts that
>>>> interact with GRASS to perform various workflows. I have debated
>>>> about converting these to Python using Rpy2, although this package
>>>> can be a difficult to install on all platforms and depends on
>>>> specific versions of R and Python. I noticed that Moritz Lennert
>>>> recently developed a GRASS add on which consists of simply writing
>>>> out the R commands to a temporary script for R to run.
>>> [...]
>>>> Does this represent a desirable or even acceptable approach for
>>>> embedding R scripts into grass add ons, or is Rpy2 the 'official'
>>>> approach.
>>> I wouldn't consider my approach in any way official, but AFAIK, rpy2
>>> does not have any "official" status in GRASS either. In my particular
>>> case (v.class.mlR) this was a quick and dirty hack for a course I had to
>>> teach. The difficulty of getting rpy2 installed on the lab machines on
>>> short notice was one of the motivations not to use it. I also agree that
>>> dependency on rpy2 can be a nuisance and has caused me some headaches
>>> with other modules, before. However, the approach I used (and others
>>> have used before) is a bit unwieldy and makes maintaining such modules a
>>> bit of a pain.
>>>
>>> So, I'm curious to hear the opinions of others...
>> See [1] for a related issue.
>>
>> Moritz
>>
>> [1] https://trac.osgeo.org/grass/ticket/1290
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev



More information about the grass-dev mailing list