Exercise 1

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.

# Tree locations
urkiola.sf <- st_read("../datafiles/urkiola/urkiola.shp")
## Reading layer `urkiola' from data source 
##   `C:\Users\sherl\OneDrive\Documents\GRAD SCHOOL II\Geog 6000 - SpatialStats\datafiles\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("../datafiles/urkiola/urkiolaWindow.shp")
## Reading layer `urkiolaWindow' from data source 
##   `C:\Users\sherl\OneDrive\Documents\GRAD SCHOOL II\Geog 6000 - SpatialStats\datafiles\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.ppp(urkiola.ppp, use.marks = T, 
     main = "Tree Locations",
     cols = c("darkgreen", "darkorange"))

1. Give the intensity (spatial density) of the combined set of two tree species by using the 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

The average intensity for the two tree species is 0.066 plants per square unit.

2. 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)

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

plot(split(urkiola.ppp),
     main = "Distribution of Tree Species")

plot.ppp(oak, 
         main = "Birch Tree Locations",
         use.marks = T, cols = "darkorange")

plot.ppp(birch, 
         main = "Oak Tree Locations",
         use.marks = T, cols = "darkgreen")

3.Now make plots of the kernel density of each species, and compare these plots. Do they suggest that the two species co-occur within the park?

plot(density(oak, sigma = 5),
     main = "Oak Tree Distribution",
     xlab = "Sigma = 5")

plot(density(birch, sigma = 5),
     main = "Birch Tree Distribution",
     xlab = "Sigma = 5")

The density plots suggest that the trees have separate spatial distribution around the park. It appears that oak trees are distributed more uniformly across the southern 2/3rds of the park, where birch trees are distributed more on the park boundaries with the densest thickets in the most southern part of the park.

It looks like oak trees are growing differently than birch trees, but it is not completely clear that they do or do not co-occur.

4.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 will give the significance level of the Monte Carlo test.

k_oak <- Kest(oak)

plot(k_oak,
     main = "K-function for Oak Trees")

The estimated K-function (\(\hat{K}_{iso}(r)\)) is above the theoretical line (\(K_{pois}(r)\)) which suggests that the oak trees have a clustered instead of random distribution.

k_birch <- Kest(birch)

plot(k_birch,
     main = "K-function for Birch Trees")

The estimated K-function (\(\hat{K}_{iso}(r)\)) for birch trees is almost the same as the theoretical line (\(K_{pois}(r)\)), suggesting that birch trees are randomly distributed around the park.

To test the hypothesis that the distributions of both tree species is random, we use the envelope function.

mc_oak <- envelope(oak,
                   fun = 'Kest',
                   nsim = 99,
                   verbose = FALSE,
                   global = T)

summary(mc_oak)
## 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
plot(mc_oak, shade = c("hi", "lo"),
     main = "Monte Carlo Simulation for Oak Tree Distribution")

For oak trees, the estimated K-function (\(\hat{K}_{iso}(r)\)) is above the theoretical line (\(K_{pois}(r)\)) and well above the bounds of the simulated confidence interval. The significance level for this test is 0.01, which means that there is little evidence that oak tree distribution arises purely from chance. This suggests that the oak trees have a clustered instead of random distribution.

mc_birch <- envelope(birch,
                     fun = 'Kest',
                     nsim = 99,
                     verbose = FALSE,
                     global = T)

summary(mc_birch)
## 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
plot(mc_birch, shade = c("hi", "lo"),
     main = "Monte Carlo Simulation for Birch Tree Distribution")

For birch trees, the estimated K-function (\(\hat{K}_{iso}(r)\)) is barely above the theoretical line (\(K_{pois}(r)\)) at high \(r\) values. The significance level for this test is also 0.01, which means that there is little evidence that the distribution of birch trees was due purely to chance. This suggests that the oak trees have a clustered distribution.

5. 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

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

summary(kc_trees)
## Pointwise critical envelopes for "K"["birch", "oak"](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(kc_trees,
     shade = c("hi", "lo"),
     main = "Cross-Dependence between Oak and Birch Trees")

For estimated K-function (\(\hat{K}_{iso}(r)\)) for cross occurance between the species is inside of the significance levels for the theoretical line (\(K_{pois}(r)\)), suggesting that the distribution between the species is random.


fin