Skip to content

Commit a30a9dd

Browse files
committed
Merge pull request #992 from fsdias/master
Fix Relative_distribution_(distance_covariate).rsx
2 parents c3f4bef + fb08949 commit a30a9dd

File tree

2 files changed

+45
-42
lines changed

2 files changed

+45
-42
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
##Layer=raster
2+
##Raster processing=group
3+
##Dens_or_Hist=string Hist
4+
##showplots
5+
library(rpanel)
6+
library(rasterVis)
7+
str <- Dens_or_Hist
8+
if (str !='Dens' & str != 'Hist'){
9+
rp.messagebox('you must enter "Dens" or "Hist"', title = 'oops!')
10+
} else {
11+
if (nbands(Layer) == 1) {
12+
Layer <- as.matrix(Layer)
13+
Layer <- raster(Layer)
14+
}
15+
if (str == 'Dens') {
16+
densityplot(Layer)
17+
} else if (str == 'Hist') {
18+
histogram(Layer)
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,25 @@
1-
(dp0
2-
S'ALG_DESC'
3-
p1
4-
VThis algorithm creates a graph that demonstrates the dependency of the intensity of the point process on the value of covariate. In this algorithm the covariate is the distance to the certain objects. The functionality is based on 'rhohat' function of the 'spatstat' package. \u000a\u000aR dependencies: library "maptools", "spatstat" and "rpanel".
5-
p2
6-
sS'ALG_CREATOR'
7-
p3
8-
VYury Ryabov\u000a2013\u000ariabovvv@gmail.com
9-
p4
10-
sS'Layer'
11-
p5
12-
VThe point process which distribution will be investigated.
13-
p6
14-
sS'Covariate_name'
15-
p7
16-
VThis field is mandatory. Enter the name of the covariate. It will appear at the graph.
17-
p8
18-
sS'Legend_position'
19-
p9
20-
VThis field defines the position of the legend at the graph. 'float' means that the legend will be placed at the position that would not overlap the graph itself (or will try at least). Other options are: 'topleft', 'topright', 'bottomleft', 'bottomright'.
21-
p10
22-
sS'x_label'
23-
p11
24-
VOptional label for the X axis. Note that units at the X axis will be the same as in the input layers.
25-
p12
26-
sS'RPLOTS'
27-
p13
28-
VThe empirical graph of the dependency of the intensity of the point process on the distance to the given objects.
29-
p14
30-
sS'ALG_HELP_CREATOR'
31-
p15
32-
VYury Ryabov\u000a2013\u000ariabovvv@gmail.com
33-
p16
34-
sS'Plot_name'
35-
p17
36-
VOptional plot name.
37-
p18
38-
sS'Covariate'
39-
p19
40-
VThe set of objects the distance from which will be calculated and used as a spatial covariate to the point process.
41-
p20
42-
s.
1+
##Point pattern analysis=group
2+
##Layer=vector
3+
##Covariate=vector
4+
##Covariate_name=string mandatory_covariate_name_(no_spaces)
5+
##x_label=string
6+
##Plot_name=string
7+
##Legend_position=string float
8+
library(spatstat)
9+
library(maptools)
10+
library(rpanel)
11+
if (Covariate_name == "") {
12+
rp.messagebox('Covariate name must not be emply!', title = 'oops!')}
13+
else {
14+
S <- Layer
15+
SP <- as(S, "SpatialPoints")
16+
P <- as(SP, "ppp")
17+
r <- Covariate
18+
rp <- as.psp(r)
19+
rdist <- distfun(rp)
20+
plot(rhohat(P, rdist, covname=Covariate_name), xlab= x_label,
21+
legendpos = Legend_position,
22+
legendargs=list(bg="transparent"),
23+
main = Plot_name)
24+
##showplots
25+
}

0 commit comments

Comments
 (0)