[R-sig-Geo] A Qgis Map Graphics Device for R

Bacou, Melanie mel at mbacou.com
Thu Aug 18 08:58:56 CEST 2016


Barry,
This looks great. Til now I've been using `tmap` (with leaflet) to 
explore spatial data interactively and to print maps within R, but a 
QGIS widget offers interesting options for creating and re-using styles.

What about editing features within the widget as well (e.g. 
merging/splitting/fixing bad geometries)? That's one of my typical 
use-case for switching between QGIS and R. Another use-case is to 
visually select and edit multiple features at once (easier in QGIS than 
in R typically).

Just curious as to how others would want to use a QGIS map canvas...

--Mel.


On 8/17/2016 10:54 AM, Tim Keitt wrote:
> We think alike -- I'd been thinking of stealing the QGIS widget for R
> mapping as well. I look forward to trying out.
>
> THK
>
> http://www.keittlab.org/
>
> On Wed, Aug 17, 2016 at 2:40 AM, Barry Rowlingson <
> b.rowlingson at lancaster.ac.uk> wrote:
>
>> Time to announce my little summer side project...
>>
>> `pqgisr` is a *highly* experimental package to provide an easy way for
>> R programmers to use the cartographic features of Qgis without the
>> hassle of exporting objects, loading them into Qgis, and then having
>> to style them.
>>
>> The package provides functions for adding map data from SP-class
>> objects, OGR, and GDAL data sources as well as basemap tile layers to
>> a Qgis map canvas window. Note that a full Qgis application is not
>> running - just a map canvas launched from R via python code. The
>> canvas is embedded in a small application with a little functionality
>> for layer styling, ordering, zooming etc.  This gives you an
>> interactive map for exploring spatial data.
>>
>> In this way I also hope to have a solution for reproducible map
>> graphics from R using the Qgis graphics engine. An R script, possibly
>> running in a knitr document, can add map data to the canvas, style it
>> either via simple R calls or using Qgis XML styling files created
>> elsewhere, then save as an image and include in a reproducible
>> document. Yes you could do all this via R graphics commands but the
>> Qgis map canvas has some features that are not available on R graphics
>> devices.
>>
>> I started this project when I noticed the RQGIS project could have
>> been implemented using `rPython`, which embeds a python interpreter
>> instance in the R process, instead of launching separate python
>> processes every time. As I considered reimplementing RQGIS using
>> rPython I realised my time would be better spent doing something that
>> couldn't be easily done using the process approach, and worked on
>> embedding a Qgis application in R via rPython. This also fit well with
>> my usual workflow which is to do all my GIS analysis in R (using rgeos
>> etc) but then exporting to Qgis for mapping. That export/import step
>> really jarred.
>>
>> I appreciate the work the RQGIS developers are doing and see `pqgisr`
>> as complementary to their approach. Running Qgis `processing`
>> algorithms is not on my TODO list for now, I'm concentrating on the
>> interactive graphics aspects.
>>
>> The problem with my dependence on rPython is that there seems to be no
>> Windows version at the moment. Oh well.
>>
>> The code is on gitlab:
>>
>> https://gitlab.com/b-rowlingson/pqgisr
>>
>> You'll need some dev skills to get it running, and I'd be interested
>> to hear success stories (failure stories less so, I *expect* it to
>> fail at this stage!). Documentation is almost non-existent, the README
>> is a bit out of date (there's more implemented functionality now), and
>> it will crash R if you try initialising Qgis twice. I'm also
>> considering changing the API, and a lot of the internals which might
>> simplify things and clear out some of the cruft from the earliest
>> versions which were mostly hacking at it to make something work.
>>
>> Suggestions welcome via the project gitlab tracker please!
>>
>>     https://gitlab.com/b-rowlingson/pqgisr/issues
>>
>>
>> Barry
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list