Home-range analyses in QGIS using R through Python
Contents
Anne Ghisla's Google Summer of Code project, mentored by Timothy H. Keitt
State of the art
Version 1.2.5 is available on Faunalia QGIS plugin repository (see Download section and NEWS file). Rpy is no longer supported, in favour of rpy2.
Download
The code is available on Faunalia QGIS plugin repository.
Just enable 3rd party repositories in Plugin Installer. The plugin is named HomeRange_plugin.
A SVN repository contains trunk and branches of the development. Contributors: please contact a.ghisla@studenti.uninsubria.it to ask for write access. It is important that you send patches against the current trunk, to spare time and energies... maybe the bug has already been fixed.
svn://home.prea.net/svn/HomeRange_plugin/
Documentation
Documentation is provided inside the plugin folder. A short tutorial is contained into doc subfolder. You can find suitable data on AniMove page.
Bug and wishlist
Testing is welcome! Bug reporting and wishlist about the plugin is provided by Faunalia: https://www.faunalia.it/animove/trac/.
Some discussion aroud HomeRange_plugin can be read on AniMove mailing list
For any other problem relative to plugin's dependencies (R, rpy, numpy, python itself, qgis) please browse the dedicated tracs.
Installation requirements and tested platforms
The plugin depends on:
- Python (2.5)
- R
R package adehabitat and its dependencies
R package rgdal and its dependencies
Note that these requirements, except for R packages, are the same of Carson Farmer's manageR plugin.
Current (rpy2) working configurations:
Platform |
QGIS |
Python |
R |
RPy2 |
R packages |
Debian testing |
1.0.1 |
2.5 |
2.8.1 |
python-rpy2 |
adehabitat 1.8.2 |
Windows "stable" |
1.0 preview II |
2.5 + numpy1.1.0 + pywin32-210 |
2.7.1 and 2.8.0 |
1.0.3-R-2.7.0-win32-py2.5 / rpy2 2.0.0 a2 py2.5 |
adehabitat 1.7.2 |
Windows XP sp3 |
1.0.1 (OSGeo4W) |
2.5.2 + numpy1.1.0 + pywin32-212 (OSGeo4W) |
2.8.1 |
rpy2 2.0.3 (OSGeo4W) |
adehabitat, rgdal, all their dependencies |
Old (rpy) working configurations (note: you often will need to purchase packages out from aptitude and similar tools, and HomeRange plugin v<2.0.0!):
Platform |
QGIS |
Python |
R |
RPy |
R packages |
Ubuntu 8.04 64bit |
compiled 0.10 |
2.5 |
2.6.2 |
python2.5-rpy (1.0.1-1) |
adehabitat 1.7.1 |
Ubuntu 8.10 |
1.0.1 |
2.5.2 + numpy1.1.1 |
2.7.1 |
rpy 1.0.3 |
adehabitat, rgdal, all their dependencies |
Debian Etch/Lenny |
0.11 or 1.0 preview |
2.5 |
2.7.1 and 2.8.0 |
python-rpy |
adehabitat 1.7.2 |
Windows "oldstable" |
0.9 and 0.10 |
2.5 |
2.6.2 |
RPy for <2.7.0 |
adehabitat 1.7.1 |
Windows XP sp3 |
1.0.1 (OSGeo4W) |
2.5.2 + numpy1.1.0 + pywin32-212 (OSGeo4W) |
2.6.2 |
rpy 1.0.3 (OSGeo4W) |
adehabitat, rgdal, all their dependencies |
Install them with the R command install.packages("<name of the package>", dep = TRUE)
R 2.7.0 can't load adehabitat, because its latest version (1.7.2) requires 2.7.1. So R 2.7.0 is not suitable.
Platform notes
Gnu/Linux
Debian Lenny can provide up-to-date R and rpy/rpy2 versions using Sid repositories - see here for detailed instructions. Debian Squeeze (testing) ships R 2.8.2.
MS Windows
OSGeo4W (http://trac.osgeo.org/osgeo4w/) 1.0.1 now provides rpy/rpy2 (rpy available in OSGeo4W is just for R 2.6.2) install options so the installer IS FINALLY SUITABLE for the Home Range plugin. Under Windows, use the OSGeo4W installer to install python, numpy, pywin32, rpy or rpy2 libraries plus R with adehabitat and rgdal packages (Python and numpy, pywin32, rpy (or rpy2) libraries MUST be installed with the OSGeo4W installer).
Into the code: List of available layers
6th week report is about combobox population with all available point layers. It is possible to get the layer list from MapCanvas, i.e. the part of the main window where checked layers are shown. If no layer is checked, nothing is displayed in MapCanvas, and the retrieved list is empty.
I solved this retrieving the list of loaded layers from an instance of QgsMapLayerRegistry. This list contains all layers shown in Legend, both checked and unchecked. This way, the point layer named "samplepoints" is present in the box even if absent from the Canvas.
I guess it's a better implementation, because there is no need of displaying data when using my plugin. If the layers I'm working on are large, checking them in order to add them to the list of available layers could be a long and unuseful operation.
Here are a couple of screenshot:
Timeline
Week |
Planned |
Done? |
Report |
1 - from 26.5 |
polish R code, refactor, test |
|
none |
2 - from 2.6 |
set up repo and work on R code |
|
|
3 - from 9.6 |
(prepare Java exam) |
|
|
4 - from 16.6 |
set up the GUI |
|
|
5 - from 23.6 |
work on GUI |
|
|
6 - from 30.6 |
connected to R and QGIS Legend |
|
|
7 - from 7.7 |
MCP analysis complete |
|
|
8 - from 14.7 |
refactorisation |
|
|
9 - from 21.7 |
merged python files into plugin.py, deep interface refactoring |
|
|
10 - from 28.7 |
beta version, further functionality, testing |
|
|
11 - from 4.8 |
improvements |
|
|
12 - from 11.8 |
documentation |
|
|
13 - from 18.8 |
(holiday in Belgium) |
|
[link] |
14 - from 25.8 |
|
|
[link] |