Read in Data
# Tree locations
urkiola.sf <- st_read("urkiola.shp")
# Park boundary
urkiola.win <- st_read("urkiolaWindow.shp")
urkiola.win <- as.owin(urkiola.win)
# First extract coordinates
urkiola.crds <- st_coordinates(urkiola.sf)
## Convert to ppp
urkiola.ppp <- ppp(x = urkiola.crds[, 1], y = urkiola.crds[,2], 
                   marks = as.factor(urkiola.sf$tree), window = urkiola.win)
Plot tree and park boundary
plot(urkiola.ppp)

Intensity using summary function
summary(urkiola.ppp)
## Marked planar point pattern:  1245 points
## Average intensity 0.06564029 points per square unit
## 
## Coordinates are given to 1 decimal place
## i.e. rounded to the nearest multiple of 0.1 units
## 
## Multitype:
##       frequency proportion  intensity
## birch       886  0.7116466 0.04671269
## oak         359  0.2883534 0.01892760
## 
## Window: polygonal boundary
## single connected closed polygon with 44 vertices
## enclosing rectangle: [0.05, 219.95] x [0.05, 149.95] units
##                      (219.9 x 149.9 units)
## Window area = 18967 square units
## Fraction of frame area: 0.575
Plot the distribution of the two tree species
plot(split(urkiola.ppp), main = "All marks")

Kernel Density plot
plot(density(split(urkiola.ppp)))

From the density plots, there is little overlap between the species in the park.

Ripley’s K Function Oak
urkoak = split(urkiola.ppp)$oak
urkbirch = split(urkiola.ppp)$birch

oak.kest = Kest(urkoak)
plot(oak.kest)

oakkest.mc = envelope(urkoak, fun='Kest', nsim=99, verbose=FALSE)
plot(oakkest.mc, shade=c("hi", "lo"))

summary(oakkest.mc)
## Pointwise critical envelopes for K(r)
## and observed value for 'urkoak'
## Obtained from 99 simulations of CSR
## Alternative: two.sided
## Upper envelope: pointwise maximum of simulated curves
## Lower envelope: pointwise minimum of simulated curves
## Significance level of Monte Carlo test: 2/100 = 0.02
## Data: urkoak

The oak tree species spatial distribution shows a clustered pattern.Using the summary function, the significance level of Monte Carlo test was 2/100 = 0.02.

Ripley’s K Function Birch
birch.kest = Kest(urkbirch)
plot(birch.kest)

birchkest.mc = envelope(urkbirch, fun='Kest', nsim=99, verbose=FALSE)
plot(birchkest.mc, shade=c("hi", "lo"))

summary(birchkest.mc)
## Pointwise critical envelopes for K(r)
## and observed value for 'urkbirch'
## Obtained from 99 simulations of CSR
## Alternative: two.sided
## Upper envelope: pointwise maximum of simulated curves
## Lower envelope: pointwise minimum of simulated curves
## Significance level of Monte Carlo test: 2/100 = 0.02
## Data: urkbirch

The birch tree species spatial distribution also shows a clustered pattern. Using the summary function, the significance level of Monte Carlo test was 2/100 = 0.02.

Cross-dependence
urkiola1.kc <- envelope(urkiola.ppp, 
                      Kcross,
                       i = "oak", 
                       j = "birch",
                       nsim = 99, 
                       verbose = FALSE)

plot(urkiola1.kc)

summary(urkiola1.kc)
## Pointwise critical envelopes for Kcross["oak", "birch"](r)
## and observed value for 'urkiola.ppp'
## Obtained from 99 simulations of CSR
## Alternative: two.sided
## Upper envelope: pointwise maximum of simulated curves
## Lower envelope: pointwise minimum of simulated curves
## Significance level of Monte Carlo test: 2/100 = 0.02
## Data: urkiola.ppp

The combined distribution of tree species is random because the observed curved follows the expected line, within the envelope.