Skip to content

Qgis and R ?

8 messages · Agustin Lobo, G. Allegri, Barry Rowlingson +1 more

#
Hi!

Does anyone has experience at displaying spatial R objects
with QGis (perhaps using the python console + Rpy or RSpython)?
I'm thinking on starting some testing and would like to know
about previous experiences.

Thanks
#
Agustin Lobo wrote:
I've done a bit of work on this and I think the current best option 
would be to save the R Spatial objects as shapefiles and then load them 
into QGis. For raster data I save as ESRI Ascii Grid format.

  Here's some other ideas:

   * write a data provider for QGis in Python that uses Rpy to fetch the 
data from an R Spatial object stored in a .RData file.

     Advantages: neat and well-integrated

     Disadvantages: tricky. might need some changes to the QGis C++ 
codebase. Only works in QGis.

   * write a GDAL/OGR driver for R Spatial objects.

     Advantages: every project that uses GDAL/OGR can use it. Frank 
Warmerdam would think it's a good idea.

     Disadvantages: would have to be in C++, I'm not sure how to write 
GDAL/OGR drivers that use external libraries (libR.so in this case).

I think writing the GDAL/OGR driver would be the right thing in this 
case, but it would require someone with lots of R and C experience to 
code it up. Start here: http://www.gdal.org/ogr/ogr_drivertut.html

Barry
#
G. Allegri wrote:
So you are sitting in front of QGis and there's some R-spatial objects 
sitting in a .RData file. How do we get that into QGis?

  How about the user selects an option 'Load R-spatial Data Object', 
browses the .RData file and chooses the object, then Rpy uses RGdal 
converts it to a shapefile or raster, then QGis loads that in? Is that 
the solution you are thinking of?

  That's an easy solution, but it's a looser coupling than being able to 
read R-spatial objects directly, and it requires an extra file creation. 
  Code-wise it's quite straightforward... I already have an R object 
browser written in PyQt and Rpy!

Barry
#
At 9:00 AM +0000 12/4/07, Barry Rowlingson wrote:
For what (little?) it's worth, I have been doing this quite a bit, 
lately. I sometimes edit the objects in QGis, then reload them into R.