Monday, July 16, 2012

Getting the SDA2PP plugin to work in QGIS. RPy2

Installing this plugin has proved to be a prolonged process.  I want to do Krigin and other interpolations in QGIS and have tried to install this plugin for these purposes.

To start off with the plugin was not even available on the list under Plugins>Fetch Python Plugins

After some searching and experimeting i found the plugin by selecting show all plugins, including experimental ones, although it does not appear to be experimental.
After selecting this option it became clear that much previous packages etc are required. These include rgdal, sp, RPy2, pywin32, numpy and an update of the python framework on my machine.  I am using a 64bit machine but it is not easy to work within a 64 bit pytho framework as many of the additional packages and moodules are not easily obtainable for 64 bit but only in 32 bit.  I therefore have kept to 32 bit to save headaches.

Most of the installs are not too complicated and can be found easily.  However I have struggled to install RPy2.

There is no precompiled self installing package for Rpy2 so it has to be done in another way.  The recommended way that i have had the most success with is using easyinstall, part of a package that is called setup tools.  I was able to install this package without any problems but could not get easy install to work.  Easy install downloads and installs packages etc from PyPI with the simple command
>easy_install rpy2
It is not all that simple however.  For this command to work the following is necessary after installation:

  • Ensure that the Command Prompt is being used and not the Python command line.
  • The Path variable needs to contain the directory in which easy_install.exe is... C:\Python27\Scripts\
  • The path also needs to contain a directory for the R executable.
Changing the Path variable is done as shown in the following figure


http://code.google.com/p/sda4pp/downloads/detail?name=SDA4PP-System-0.9.0.exe&can=2&q=#makechanges

Installing Rpy2 on windows does not appear to be possible at this stage.  I am switching to linux.


Thursday, July 5, 2012

Modelling individual tree in R using R Commander

And so I experiment modelling my tree data to get some kind of correlation between the coordinates and the tree size...  Also just to get a feel of the R commander GUI and the possibilities that R presents.  What I actually want to do is get an equation for the regression graph that was obtained in the previous post:




First it is necessary to create a model... tree size as a function of x and y coordinate!


Plotting Individual tree data in R. Windows,R Commander

I have switched to a 64-bit windows operating system and have also collected some of my own individual tree data using a surveyors total station.

For analysis of this data I started using  the steps as explained here.  However, I was unused to the windows interfadce and could not locate the command history window.  Doing some research to find the solution I came across an interesting GUI for R called R commander. It offer a variety of the analysis tools in drop down list form to from the commands that are then used as command lines.  This helps beginners like myself to get quicker results and also helps me to see what can be done in R.


Being a lover of 3d representations, plotting my data in 3d is one of the first things that I tried.

Importing the .csv data:


Name the dataset, ensure that "commas" is selected and the correct decimal -point character
On the tpop of the interface the active dataset is now displayed and one can view the data or edit the data directly in cells as in a spreadheet which is very useful.


One the dataset is active any of the manipulations from the above menus can be carried out. My selection: "3D Scatterplot"


The options are as follows:

I selected DBH as response variable and the x and y coordinates of the tree positions as explanatory variable and I wanted to see the smooth regression.  The result, a nice representation of the spatial distribution of tree size:
Saving the graph to file is an option in the R Commander GUI in the "Graphs" menu.

Now to get some kind of equation for this regression.... Modeeling in R using R Commander

Collecting Individual tree data Using a Surveyor's Total Station