[R-sig-Geo] Load R sp vector layers in QGIS

Agustin Lobo aloboaleu at gmail.com
Thu Jun 19 16:40:35 CEST 2008


R is capable of some very limited display of geographic
information and there are no interactive tools for
the geographic exploration of displayed geodata. If the current
set of tools is enough for you, congratulations. But,
for example, yesterday I got the data of a bunch of
points arranged as transects which contain data of
animal tracks in Bolivia. Once I imported the shp
as an sp object and displayed it, the first thing I wanted
to do was zooming in certain zones, which
I could not do in R. Also, i could not display these
data on top of other many geospatial data I have for the
area. These type of operations are better done in a GIS.
On the other hand, thanks to its flexibility,
R is very good at highlighting some features (for example,
get all consecutive points where the same sp had been observed
and which had been taken within a time lapse less than 2 min).
You can also do some of these operations in some GIS, but
doing it in R is faster and more powerful.
Thus being able of displaying R spatial objects in a real
GIS would be great, at least for some of us.

The current solution of saving to an rda file is an step forward
to the goal of displaying R spatial objects directly in a GIS
display with no intermediate steps for the user.
As soon as I test it, I'll be able to tell if this is better than
saving to shp, but I guess it is. Note than, at least in my case, I
would do this type of operation very often, so even an slight
improvement made by eliminating an intermediate step can be
of interest. An example: you can get a nice RGB composite
display in R, but it would take you several minutes (provided you
remember how to do it) and a waste of disk space, while it would take 
you few seconds in QGIS. This is not important if you have to do it
occasionally, but it is if you do it often.

Agus


Paul Hiemstra wrote:
> Hi Carson,
> 
> Is exporting the Spatial object to a .shp (or other vector format) and 
> then reading the file in to QGIS not an easier way to get R spatial 
> layers into QGIS. That also solves the problem of not being able to edit 
> the features. If you edit in QGIS and save you can read the file back 
> into R.
> 
> R is also capable of displaying GIS information quite nicely (spplot). I 
> tried several programs under Linux to create map output (QGIS, udig,  
> for journal articles and ended up using R. R certainly has a steeper 
> learning curve, but the output from the version of QGIS I used (0.9.2) 
> was not good enough for me.
> 
> So my question is, what is the big advantage of getting R data into QGIS 
> in this way.
> 
> cheers,
> Paul
> 
> cfarmer wrote:
>> Hello lists,
>>
>> Apologies for cross posting, but I thought this might be of interest to
>> all groups...
>>
>> Thanks to the excellent work of Martin Dobias on the QgsMemoryProvider, I
>> have created a simple plugin which acts as an additional file type 
>> handler
>> for R sp vector objects in QGIS.
>>
>> To use:
>> 1) In R ( or manageR ;) ), create an sp vector object
>> (SpatialPointsDataFrame, SpatialPolygonsDataFrame, 
>> SpatialLinesDataFrame).
>> 2) Save the sp object to a .Rdata file
>> 3) Enable the plugin in QGIS (the button should appear in the file 
>> toolbar
>> along with 'add vector layer', 'add raster layer', etc..
>> 4) Click 'loadRlayer' button, and browse to your .Rdata file
>> 5) The plugin should do the rest, and voila! Your R spatial layer should
>> be displayed on the QGIS map canvas.
>>
>> To get it:
>> 1) It is available from: 'http://www.geog.uvic.ca/spar/carson/'
>> or
>> 2) Add 'http://www.geog.uvic.ca/spar/carson/cfarmerQgisRepo.xml' to your
>> repositories list in QGIS
>>
>> Notes:
>> 1) When possible, the spatial reference information is taken from the sp
>> object
>> 2) The name is also taken from the sp object, not the name of the 
>> .Rdata file
>> 3) Your .Rdata file should only contain a single sp object
>> 4) I haven't tested this on multipoint or multiline features...?
>> 5) You should be able to do all the normal things that vector layers in
>> QGIS can do (except for save edits).
>> 6) Note that at this point, changes to the layer in QGIS will not be
>> reflected in the initial sp object, thus, this plugin is primarily for
>> visualizing your sp vector objects.
>>
>> Hope you enjoy!
>>
>> Carson
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>   
> 
> 

-- 
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es
http://www.ija.csic.es/gt/obster




More information about the R-sig-Geo mailing list