[GIS] Ripley’s K function in QGIS Chugiak 2.4

errorqgisqgis-2.4r

I need to apply the Ripley's K-function on a point pattern in QGIS 2.4 Chugiak, but I don't know how to do. I think I need to use some plugin or extension (maybe GRASS, R or something), but I haven't found neither clear nor structured solution about it.

Best Answer

I use QGIS 2.2 so what I post may differ in certain areas. You can install the Processing plugin via:

Plugins > Manage and Install Plugins...

Manage plugins

Once installed, you should see the Processing menu in your toolbar. Select Options and Configuration:

Processing toolbar

Select the Providers list, find R scripts, check the Activate box and set the path of the R folders:

R menu

Next select the Processing menu in your toolbar again and choose Toolbox:

Processing toolbox

You should be able to see the R scripts that are available.

R scripts

For me, QGIS 2.2 did not have the K script so I copied it from QGIS 2.0. I do not know if QGIS 2.4 will contain it. If you cannot run any R scripts then you can follow the advice given here which may mean you have to download and install the rgdal package separately. Hope this helps!


EDIT

The following is what's contained within my version of the K function script:

##points=vector
##showplots

library("maptools")
library("spatstat")

ppp=as(as(points, "SpatialPoints"),"ppp")
plot(envelope(ppp, Kest, nsim=100))

EDIT

Finally I found this script. It combines "taughts" from Joseph's one, others found in the web and similarities with other de facto algorithms which comes with PROCESSING plugin (as F or G functions, etc). This script computes Ripley's K function with L(d)-d conversion, title and subtitle can be write, and then enables to compute number of MonteCarlo simulations as you wish (de facto is fixed in 99 but it can be change in the main menu). Although, it is important not to save any result previously (i.e. let "R Plots" empty in the main menu)

##Point pattern analysis=group
##Layer=vector
##Simulations=number 99
##Title=string
##Subtitle=string
##showplots

library("maptools")
library("spatstat")

ppp=as(as(Layer, "SpatialPoints"),"ppp")
L=envelope (ppp, Lest, nsim=Simulations)
plot(L, . - r ~ r, main=Title, sub=Subtitle)
Related Question