Instructions: The zip file urkiola.zip contains two shapefiles. The first urkiola.shp contains point locations of two species of tree (oak and birch) in a Spanish National Park. The second, urkiolaWindow.shp, contains the park boundary as a polygon. Code for reading in these files, and converting them into a point process object (ppp) is given below. Once you have obtained the ppp object: - Give the intensity (spatial density) of the combined set of two tree species by using the summary() function - Plot the distribution of the two tree species as separate figures. You will need to use the split() function to access the data by individual species (e.g. split(urkiola.ppp)$oak will return only the location of the oak trees)

# Tree locations
urkiola.sf <- st_read("./urkiola/urkiola.shp")
## Reading layer `urkiola' from data source 
##   `/Users/brenna/Documents/School/GEOG 6000/Lab 14/urkiola/urkiola.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 1245 features and 5 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: 2.1 ymin: 0.1 xmax: 219.1 ymax: 149.9
## CRS:           NA
# Park boundary
urkiola.win <- st_read("./urkiola/urkiolaWindow.shp")
## Reading layer `urkiolaWindow' from data source 
##   `/Users/brenna/Documents/School/GEOG 6000/Lab 14/urkiola/urkiolaWindow.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 1 feature and 3 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: 0.05 ymin: 0.05 xmax: 219.95 ymax: 149.95
## CRS:           NA
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(urkiola.ppp)

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

Answer: The average number of birch trees per unit (intensity) is 0.05, and 0.02 for oak trees. There are more than twice as many birch trees than oak trees.

urkiola.split <- split(urkiola.ppp)
oak <- urkiola.split$oak
birch <- urkiola.split$birch

oak.qc <- quadratcount(oak, nx = 6, ny = 4)
birch.qc <- quadratcount(birch, nx = 6, ny = 4)

par(mfrow = c(1, 2))
plot(oak.qc, col = rev(brewer.pal(5, "Greens")), main = "Oak Tree Distribution")
plot(birch.qc, col = rev(brewer.pal(5, "Greens")), main = "Birch Tree Distribution")

par(mfrow = c(1, 2))
plot(density(oak, sigma = 20), main = "Oak Density")
plot(density(birch, sigma = 20), main = "Birch Density")

Answer: There are areas of co-occurrence, in the southeast and parts of the north, but I don’t think there is a strong spatial relationship between the two. There are fewer birch trees along the BI-623 (a highway in the Biscay province of the Basque country), but even fewer around the mountains. Oak trees love limestone, which is abundant in the area, which may explain why they are distributed relatively evenly in and around the rocky regions. The spatial distribution may also be related to logging activity.

Instructions: Using Ripley’s K function, examine the individual distributions of the two species for non-random spatial organization. Use the envelope() function to test the obtained Ripley’s K against a hypothesis of Complete Spatial Randomness. Plot the results and state whether or not each species has a random distribution or not, and if not, whether the trees are clustered or have a regular distribution. Note that using summary() on the output of the envelope() function with give the significance level of the Monte Carlo test

birch.kest <- Kest(birch)
oak.kest <- Kest(oak)

par(mfrow = c(1, 2))
plot(birch.kest, main = "Ripley's K: Birch")
plot(birch.kest, main = "Ripley's K: Oak")

Answer: There is evidence of some clustering, but I would like to see if this is significant.

birch.kest.mc <- envelope(birch,
                          fun = 'Kest',
                          nsim = 99,
                          verbose = FALSE,
                          global = TRUE)

oak.kest.mc <- envelope(oak,
                        fun = 'Kest',
                        nsim = 99,
                        verbose = FALSE,
                        global = TRUE)

summary(birch.kest.mc)
## Simultaneous critical envelopes for K(r)
## and observed value for 'birch'
## Obtained from 99 simulations of CSR
## Alternative: two.sided
## Envelopes computed as theoretical curve plus/minus maximum simulated value of 
## maximum absolute deviation
## Significance level of Monte Carlo test: 1/100 = 0.01
## Data: birch
summary(oak.kest.mc)
## Simultaneous critical envelopes for K(r)
## and observed value for 'oak'
## Obtained from 99 simulations of CSR
## Alternative: two.sided
## Envelopes computed as theoretical curve plus/minus maximum simulated value of 
## maximum absolute deviation
## Significance level of Monte Carlo test: 1/100 = 0.01
## Data: oak
par(mfrow = c(1, 2))
plot(birch.kest.mc, shade = c("hi", "lo"))
plot(oak.kest.mc, shade = c("hi", "lo"))

Answer: Both estimates of Ripley’s K (particularly oak) diverge from the global envelope, and both results are significant at the 0.01 alpha level.

Instructions: Finally, test the spatial dependence between the two distributions to test if the two species truly co-occur or not. Use the envelope() function again, but with the Kcross() function to estimate the cross-dependence. Plot the results and state whether the distributions of the two species show positive, negative or no correlation with each other

urkiola.kc <- envelope(urkiola.ppp, 
                       Kcross, 
                       i = "oak", 
                       j = "birch",
                       nsim = 99, 
                       verbose = FALSE)
summary(urkiola.kc)
## Pointwise critical envelopes for "K"["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
plot(urkiola.kc)

Answer: Because the curve is contained within the envelope, the combined spatial distribution of birch and oak trees is random, with neither negative or positive correlation between the two.