6

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.

8

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)
  • Thanks, but my problem persists. QGIS 2.4 doesn't incorporate the K script, then I copied it from link but gives me the following error ("..." means file folder): File "...", line 259, in accept command = self.alg.getAsCommand() File "...", line 513, in getAsCommands += out.getValueAsCommandLineParameter() + ',' File "...", line 64, in getValueAsCommandLineParameter return '"' + str(self.value).replace('\\', '\\\\') + '"' UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 45: ordinal not in range(128) – Milos Oct 1 '14 at 14:04
  • Do any of the R scripts run or do they also produce an error? – Joseph Oct 1 '14 at 14:07
  • I tried the solution that your link said too, modifying the script folder path and copy-pasting the R libraries in the default folder too. But none. – Milos Oct 1 '14 at 14:09
  • 2
    No worries :). Strange, I will edit your question in the hope that someone more qualified than me can solve this problem. However, I will see if I can find some more info about this. – Joseph Oct 1 '14 at 14:20
  • 1
    Your QGIS is cursed! I've edited my post to include a K-Function script, slightly different from your link. But yes, hopefully someone will provide an answer if this does not work either. – Joseph Oct 1 '14 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.