library(landscapemetrics)
library(landscapetools)
library(raster)
library(tidyverse)
library(janitor)
#Add code importing esett and psett rasters here
## Import a raster and plot it. 
esett <- raster("data/esett.asc")
psett <- raster("data/psett.asc")
show_landscape(esett,discrete = TRUE)

show_landscape(psett,discrete = TRUE)

fig.cap=‘Figure 1: esett.asc and psett.asc landscape rasters showing early settlement (left) and post settlement(right). Each cell is either forested (purple), agricultural (aqua) or urban (yellow)’

Task 1: Landscape composition

Task 1.1 Calculate the total area of each class and use this to calculate the proportion of each class type in each landscape. Summarise in Table 1.1a and 1.1b (2 pts). You may want to switch to the Visual Editor to fill in these tables.

check_landscape(esett)
## Warning: Caution: Coordinate reference system not metric - Units of results
## based on cellsizes and/or distances may be incorrect.
##   layer crs units   class n_classes OK
## 1     1  NA    NA integer         3 ❓
check_landscape(psett)
## Warning: Caution: Coordinate reference system not metric - Units of results
## based on cellsizes and/or distances may be incorrect.
##   layer crs units   class n_classes OK
## 1     1  NA    NA integer         3 ❓
esett_classes <- calculate_lsm(esett, what = c("lsm_c_ca"))
## Warning: Please use 'check_landscape()' to ensure the input data is valid.
psett_classes <- calculate_lsm(psett, what = c("lsm_c_ca"))
## Warning: Please use 'check_landscape()' to ensure the input data is valid.
rbind(esett_classes,psett_classes) 
## # A tibble: 6 × 6
##   layer level class    id metric value
##   <int> <chr> <int> <int> <chr>  <dbl>
## 1     1 class     1    NA ca        59
## 2     1 class     2    NA ca        28
## 3     1 class     3    NA ca        13
## 4     1 class     1    NA ca        39
## 5     1 class     2    NA ca        32
## 6     1 class     3    NA ca        29

Table 1.1a – Early Settlement

Cover type Cells Pi
Forested 59 0.59
Agricultural 28 0.28
Urban 13 0.13
————— ——— ——-
Total 100 1

Table 1.1b – Post Settlement

Cover type Cells Pi
Forested 39 0.39
Agricultural 32 0.32
Urban 29 0.29
————— ——— ——-
Total 100 1

Task 1.2 Calculate Dominance: S is the number of land cover types Pi is the proportion of the ith land cover type. Values near 1 indicate the landscape is dominated by one land cover type; a value of zero means all cover types are equally abundant. Do this using the equation below. Summarise in Table 2 (2 pts).

Hint: use the log() and sum() functions to recreate this function in R.

#S is the number of land cover types which is 3; Forested, Agricultural, Urban 
#Pi is the proportion of the ith land cover type
pei<- c(0.59,0.28,0.13)
dominance_pre<-(log(3) + sum(pei*log(pei)))/log(3)
dominance_pre
## [1] 0.150781

The dominance value pre-settlement is 0.150781

#S is the number of land cover types which is 3; Forested, Agricultural, Urban 
#Pi is the proportion of the ith land cover type
ppi<-c(0.39,0.32,0.29)
dominance_post<-(log(3) + sum(ppi*log(ppi)))/log(3)    
dominance_post
## [1] 0.007083868

The dominance value post-settlement is 0.007083868

Task 1.3 Using the landscapemetrics package in R calculate the Shannon’s Evenness Index: Values near 0 indicate the landscape is dominated by one land cover type; a value of 1 means all cover types are equally abundant. It is a measure of dominance. Summarise in Table 1.3 (2 pts).

evenness_index_pre <-calculate_lsm(esett, #This is our input raster
                              what = c("lsm_l_shei"))#Shannon's evenness index
## Warning: Please use 'check_landscape()' to ensure the input data is valid.
evenness_index_pre  #This will print out the table
## # A tibble: 1 × 6
##   layer level     class    id metric value
##   <int> <chr>     <int> <int> <chr>  <dbl>
## 1     1 landscape    NA    NA shei   0.849
evenness_index_post <-calculate_lsm(psett, #This is our input raster
                              what = c("lsm_l_shei"))#Shannon's evenness index
## Warning: Please use 'check_landscape()' to ensure the input data is valid.
evenness_index_post  #This will print out the table
## # A tibble: 1 × 6
##   layer level     class    id metric value
##   <int> <chr>     <int> <int> <chr>  <dbl>
## 1     1 landscape    NA    NA shei   0.993

Table 1.3

Metric Pre-Settlement Post-settlement
Dominance 0.150781 0.007083868
Shannon’s Evenness Index 0.849219 0.9929161

Question 1.4 What is the relationship between Dominance and Shannon’s Evenness Index? Do you need to analyse both (1 pts)?

The relationship between Dominance and Shannon’s Evenness Index is an inverse relationship. Dominance is the exact inverse of Shannons evenness index as they represent the exact reciprical of eachother. For example (values of each taken from table 1.3) 0.150781 + 0.849219 = 1. No there is no need to analyse both metrics because if one of the two values is known, then so is the other. Evenness index itself is a “measure of dominance”

Question 1.5 How would you interpret/describe the changes in this landscape between the two time periods (2 pts)?

Comparing the values in table 1.3 - the dominance of the landscape has decreased, thus the abundance of all the cover types is more similar and is closer towards being equally abundant, and not having a single cover type such as forests covering the majority of the landscape.

Comparing the values in table 1.1a/1.1b - the total number of forested cells and subsequent overall proportion has decreased, while the total number of urban cells has increased as well as its overall proportion relative to the other cover types.

I would therefore interpret this landscape as having a lot of its forested areas that were prevalent pre-settlement removed and replaced with urban areas in their place which has more than doubled over the course of settlement. Through settlement a lot more urban areas have been developed resulting in a more heterogeneous landscape.

Task 1.6 Using Table 1.6 below calculate Shannon’s Evenness Index for each landscape. You will use these to answer the next questions in your notebook (2 pts).

pwxi<- c(0.8,0.1,0.1)
dominance_landscape_wx<-(log(3) + sum(pwxi*log(pwxi)))/log(3)

pyzi<-c(0.65,0.2,0.15)
dominance_landscape_yz<-(log(3) + sum(pyzi*log(pyzi)))/log(3)    

evenness_index_wx<- 1-dominance_landscape_wx
evenness_index_yz<- 1-dominance_landscape_yz

evenness_index_wx
## [1] 0.5816719
evenness_index_yz
## [1] 0.8068947

Table 1.6

Landscape Pforest Pagricultural Purban Shannon’s Evenness Index
W 0.1 0.8 0.1 0.5816719
X 0.8 0.1 0.1 0.5816719
Y 0.65 0.2 0.15 0.8068947
Z 0.15 0.2 0.65 0.8068947

Question 1.7 Which of these hypothetical landscapes might be considered “similar” when only comparing Shannon Evenness Index (SHEI)? Considering your interpretation of the data in Table 1.6, what other types of information and/or metrics would be necessary to distinguish these landscapes? (4 pts)

There are two combinations of hypothetical landscapes that might be considered “similar” when only comparing Shannon Evenness Index. Landscape W and landscape X, which both have the same shannon’s evenness index of 0.5816719 Landscape Y and landscape Z, which both have the same shannon’s evenness index of 0.8068947

A metric which would help distinguish these landscapes would be total class area of each landscape. This metric facilitates knowing the overall proportions (Pi) of each class type in these landscapes would give a better idea the composition of the land cover types. For example, landscapes which seem similar based on Shannon Evenness Index like landscapes W and X become easily distinguished by the proportion of the different class types. 80% of Landscape W is agricultural land cover, while 80% of Landscape X is forest land cover.

Another metric which would help distinguish these landscapes would be the number of patches and/or average patch size. This would give a good indication of the composition of the landscape and could provide insights to the heterogeneity and connectivity of each of the land cover types which would also make the landscapes more distinguishable.

Task 2: Landscape structure

Task 2.1 Using the landscapemetrics package in R calculate the Number of Patches and Mean Patch Size for each landscape and summarise in Table 2.1 (4 pts).

patches_meanarea_pre <-calculate_lsm(esett, #This is our input raster
                              what = c("lsm_c_np", #number of patches
                                        "lsm_c_area_mn"), #Mean patch area
                              directions = 4) #This is the neighborhood rule we are using
## Warning: Please use 'check_landscape()' to ensure the input data is valid.
mean_patch_pre<-sum(patches_meanarea_pre$value[1:3])/sum(patches_meanarea_pre$value[4:6])


patches_meanarea_post <-calculate_lsm(psett, #This is our input raster
                              what = c("lsm_c_np", #number of patches
                                        "lsm_c_area_mn"), #Mean patch area
                              directions = 4) #This is the neighborhood rule we are using
## Warning: Please use 'check_landscape()' to ensure the input data is valid.
mean_patch_post<-sum(patches_meanarea_post$value[1:3])/sum(patches_meanarea_post$value[4:6])

mean_patch_pre
## [1] 0.3478355
mean_patch_post
## [1] 0.121775

Table 2.1

Class type # patches - Early # patches - Post Mean patch size - Early Mean patch size - Post
Forested 7 13 8.428571 3
Agricultural 16 19 1.750000 1.684211
Urban 10 19 1.300000 1.526316

Question 2.2 What characteristics of a landscape do the number of patches and the average patch size represent (2 pts)?

The number of patches and average patch size represent the spatial structure and composition of land cover types within the landscape, as well as the number of edges.

The number of patches and average patch size also give an indication of the heterogeneity of the landscape. A patchy landscape is assumed to be hetergenous whereas a landscape with minimal patches is more likely to be homogenous and lacking dissimilar elements.

If the value for the average patch size is large, then the patches are generally large which means that the landscape is less likely to be fragmented and will have more overlap of edges and higher connectivity.

If the value for the average patch size is smaller, and or the number of patches is large then it is more likely that the landscape is more fragmented, and have a lower connectivity.

Task 2.3 You will also need to calculate the edge/area ratio (i.e. Number of Edges of class I /Total Area of class I) for each class for both the early and post settlement time periods. You can do this manually based on the outputs from the code above. Summarise these in Table 2.3 (4 pts).

edges_pre <-calculate_lsm(esett, #This is our input raster
                              what = c("lsm_c_ed",# Edge density
                                       "lsm_c_ca"), #Class area 
                              directions = 4) #This is the neighborhood rule we are using
## Warning: Please use 'check_landscape()' to ensure the input data is valid.
edges_post <-calculate_lsm(psett, #This is our input raster
                              what = c("lsm_c_ed",# Edge density
                                       "lsm_c_ca"), #Class area 
                              directions = 4) #This is the neighborhood rule we are using
## Warning: Please use 'check_landscape()' to ensure the input data is valid.
edges_pre 
## # A tibble: 6 × 6
##   layer level class    id metric value
##   <int> <chr> <int> <int> <chr>  <dbl>
## 1     1 class     1    NA ca        59
## 2     1 class     2    NA ca        28
## 3     1 class     3    NA ca        13
## 4     1 class     1    NA ed        89
## 5     1 class     2    NA ed        75
## 6     1 class     3    NA ed        40
edges_post 
## # A tibble: 6 × 6
##   layer level class    id metric value
##   <int> <chr> <int> <int> <chr>  <dbl>
## 1     1 class     1    NA ca        39
## 2     1 class     2    NA ca        32
## 3     1 class     3    NA ca        29
## 4     1 class     1    NA ed        84
## 5     1 class     2    NA ed        83
## 6     1 class     3    NA ed        85
edges_pre$value[4:6]/edges_pre$value[1:3]
## [1] 1.508475 2.678571 3.076923
edges_post$value[4:6]/edges_post$value[1:3]
## [1] 2.153846 2.593750 2.931034

Table 2.3

Class type Number of Edges- Early Number of Edges - Post Edge:Area Ratio- Early Edge:Area Ratio - Post
Forested 89 84 1.508475 2.153846
Agricultural 75 83 2.678571 2.593750
Urban 40 85 3.076923 2.931034

Question 2.4 Two landscapes are the same size and both contain the same amount of a given cover type. Landscape A has four patches of that cover type, and Landscape B has 17 patches of the same cover type. Which of the landscapes will have the higher edge to area ratio of that cover type (1 pt)?

It is edges/area so more edges will have a higher edge to area ratio and landscape B has 17 patches thus will have more edges. Therefore Landscape B will have the higher edge to area ration of that cover type.

Task 2.5 Use landscapemetrics package in R to calculate contagion and summarise in Table 2.5 (2 pts).

#Task 2.5 code here
contagion_pre <-calculate_lsm(esett, #This is our input raster
                              what = c("lsm_l_contag"), #contagion
                              directions = 4) #This is the neighborhood rule we are using
## Warning: Please use 'check_landscape()' to ensure the input data is valid.
## Warning: Number of classes must be >= 2: CONTAG = NA.
contagion_post <-calculate_lsm(psett, #This is our input raster
                              what = c("lsm_l_contag"), #contagion
                              directions = 4) #This is the neighborhood rule we are using
## Warning: Please use 'check_landscape()' to ensure the input data is valid.

## Warning: Number of classes must be >= 2: CONTAG = NA.
contagion_pre
## # A tibble: 1 × 6
##   layer level     class    id metric value
##   <int> <chr>     <int> <int> <chr>  <dbl>
## 1     1 landscape    NA    NA contag    NA
contagion_post 
## # A tibble: 1 × 6
##   layer level     class    id metric value
##   <int> <chr>     <int> <int> <chr>  <dbl>
## 1     1 landscape    NA    NA contag    NA

I had trouble with the above line of code by the code from 3.1 gave me these contagion values instead.

Table 2.5

Cover Type Pre-Settlement Post-Settlement
Contagion 15.7809317 1.620834

Question 2.6 What does the contagion value tell you about changes in landscape structure over time (2 pts)?

Contagion is a metric which conveys information about the spatial arrangement and connectivity of the patches of a landscape.

Higher values (approaching 100) indicate that the cover types of a landscape are clumped together.Landscapes of lower contagion indexs mean that cover types of a landscape are well dispersed/mixed and not aggregated all together in one spot.

The Contagion of the landscape in Table 2.5 decreases from pre-settlement to post-settlement. Pre-settlement, which has a higher contagion value had land cover types which are more aggretated or clumped together when compared to post settlement. This is most likely due to patches decreasing in size and being more mixed across the landscape.

Task 3: Neighbourhood rules

Task 3.1 Adapt the provided code to calculate the suite of landscape metrics for both neighbourhood rules. Once you have created four objects with each set of metrics, you can use the provided code to bind them into a table. Put all of your code here: (4 pts):

neighbourhood4_pre <-calculate_lsm(esett, #This is our input raster
                              what = c("lsm_c_ca", #Class area
                                       "lsm_c_np",#number of patches
                                       "lsm_c_area_mn", #Mean patch area
                                       "lsm_c_ed",# Edge density
                                       "lsm_l_shdi",#Shannon's diversity index
                                       "lsm_l_contag"), #contagion
                              directions = 4) #This is the neighborhood rule we are using
## Warning: Please use 'check_landscape()' to ensure the input data is valid.
neighbourhood4_pre$layer <- "esett4" #This gives the layer a name associated with the map and neighborhood rule so we can bind them!

neighbourhood4_post <-calculate_lsm(psett, #This is our input raster
                              what = c("lsm_c_ca", #Class area
                                       "lsm_c_np",#number of patches
                                       "lsm_c_area_mn", #Mean patch area
                                       "lsm_c_ed",# Edge density
                                       "lsm_l_shdi",#Shannon's diversity index
                                       "lsm_l_contag"), #contagion
                              directions = 4) #This is the neighborhood rule we are using
## Warning: Please use 'check_landscape()' to ensure the input data is valid.
neighbourhood4_post$layer <- "psett4" #This gives the layer a name associated with the map and neighborhood rule so we can bind them!

neighbourhood8_pre <-calculate_lsm(esett, #This is our input raster
                              what = c("lsm_c_ca", #Class area
                                       "lsm_c_np",#number of patches
                                       "lsm_c_area_mn", #Mean patch area
                                       "lsm_c_ed",# Edge density
                                       "lsm_l_shdi",#Shannon's diversity index
                                       "lsm_l_contag"), #contagion
                              directions = 8) #This is the neighborhood rule we are using
## Warning: Please use 'check_landscape()' to ensure the input data is valid.
neighbourhood8_pre$layer <- "esett8" #This gives the layer a name associated with the map and neighborhood rule so we can bind them!

neighbourhood8_post <-calculate_lsm(psett, #This is our input raster
                              what = c("lsm_c_ca", #Class area
                                       "lsm_c_np",#number of patches
                                       "lsm_c_area_mn", #Mean patch area
                                       "lsm_c_ed",# Edge density
                                       "lsm_l_shdi",#Shannon's diversity index
                                       "lsm_l_contag"), #contagion
                              directions = 8) #This is the neighborhood rule we are using
## Warning: Please use 'check_landscape()' to ensure the input data is valid.
neighbourhood8_post$layer <- "psett8" #This gives the layer a name associated with the map and neighborhood rule so we can bind them!

[Table 3.1

This will be your metrics table. You can print it in an intuitive order using this code:

allmetrics <- list(neighbourhood4_pre, neighbourhood8_pre, neighbourhood4_post, neighbourhood8_post) #This creates a list of the data tables
metric_table <- do.call(rbind, allmetrics) #This binds the tables together
metric_table <- tidyr::spread(metric_table, layer, value) #This puts the table into wide format
metric_table
## # A tibble: 14 × 8
##    level     class    id metric  esett4 esett8 psett4 psett8
##    <chr>     <int> <int> <chr>    <dbl>  <dbl>  <dbl>  <dbl>
##  1 class         1    NA area_mn  8.43  59       3     19.5 
##  2 class         1    NA ca      59     59      39     39   
##  3 class         1    NA ed      89     89      84     84   
##  4 class         1    NA np       7      1      13      2   
##  5 class         2    NA area_mn  1.75   3.5     1.68   3.56
##  6 class         2    NA ca      28     28      32     32   
##  7 class         2    NA ed      75     75      83     83   
##  8 class         2    NA np      16      8      19      9   
##  9 class         3    NA area_mn  1.3    1.86    1.53   4.14
## 10 class         3    NA ca      13     13      29     29   
## 11 class         3    NA ed      40     40      85     85   
## 12 class         3    NA np      10      7      19      7   
## 13 landscape    NA    NA contag  15.8   15.8     1.62   1.62
## 14 landscape    NA    NA shdi     0.933  0.933   1.09   1.09

Question 3.2 What metrics changed between the two neighbourhood rules and what does this mean (4 pts)?

Different neighborhood rules affect the metrics that are used to measure the edges of land cover types within a landscape. A higher number of neighborhood rules (eg. 8-neighborhood rule) will yield a lower estimate of the number of patches as the requirements of a patch based on the edge dynamics is not as easily met by areas in a landscape accepted as patches by a lower number of neighborhood rules (eg. 4-neighborhood rule).

There were a couple of class metrics which remained constant regardless of the which neighborhood rules were being used. These included edge density (ed) and class area (ca). There were also a couple of landscape metrics which remained constant which were the contagion metric (contag) and shannons diversity index (shdi).

The metrics that changed based on the two neighbourhood rules where as follows: 1. edge and area metric (area_mn) - “mean patch area” 2. number of patches (np)

‘area_mn’ values increased when going from a 4-neighbourhood rule and 8-neighbourhood rule which means that despite landscape and patch area remaining constant, the mean patch area increases when using a higher direction nighbourhood rule. Using a 4-neighbourhood rule instead of an 8-neighbourhood rule will yield smaller patches and a higher number of them.

‘np’ values increased when going from a 4-neighbourhood rule and 8-neighbourhood rule which implies that the number of patches decreases. Using a 4-neighbourhood rule instead of an 8-neighbourhood rule will yield more patches than an 8-neighbourhood rule.

Even when the landscape area and patch area remain the exact same, the values for metrics like edge and area, and number of patches come back different for when neighborhood rules are selected.

Task 4: Real maps

Task 4.1 Create maps (show_landscape code) in R for each landscapes (2 pts).

pre_fire <- raster("data/pre_fire.grd")
## Warning in .rasterFromRasterFile(grdfile, band = band, objecttype, ...): NAs
## introduced by coercion
show_landscape(pre_fire, discrete = TRUE)
Your figure caption here

Your figure caption here

post_fire <- raster("data/post_fire.grd")
## Warning in .rasterFromRasterFile(grdfile, band = band, objecttype, ...): NAs
## introduced by coercion
show_landscape(post_fire, discrete = TRUE)
Your figure caption here

Your figure caption here

Question 4.2 What is the extent and grain for the landscape (2 pts)?

post_fire
## class      : RasterLayer 
## dimensions : 436, 447, 194892  (nrow, ncol, ncell)
## resolution : 100, 100  (x, y)
## extent     : 2746899, 2791599, 2517612, 2561212  (xmin, xmax, ymin, ymax)
## crs        : +proj=lcc +lat_0=-37 +lon_0=145 +lat_1=-36 +lat_2=-38 +x_0=2500000 +y_0=2500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs 
## source     : post_fire.grd 
## names      : code 
## values     : 0, 7  (min, max)

resolution: 100, 100 (x, y) The grain (area of one cell) is 100m by 100m

ncell: 19482 The extent (area covered by entire map) of the landscape is 19482 Ha

Task 5: Landscape metrics

Question 5.1 What do each of the metrics mean (include interpretations!)? (6 pts)

Contagion is a metric which conveys information about the spatial arrangement and intermixing of the patches of a landscape, at a landscape level. Higher values (approaching 100) indicate that the cover types of a landscape are clumped/aggregaed together. Landscapes of lower contagion indexs mean that cover types of a landscape are well dispersed/mixed and not aggregated all together in one spot.

Patch Density is the number of patches/areas of homogeneous land cover relative to the area of the whole landscape. It is a metric which best describes a landscape as being the fragmented or not. A higher patch density implies that there are more patches, which are likely smaller and fragmented.

Edge Density is the total number of edges of landscape relative to the overall landscape area. This is also know as adjacency. Edge density assists in assessing if a landscape is fragmented. A higher edge density implies that a landscape has more, smaller patches as there is less a smaller area:edge ratio.

Landscape Shape Index is a ratio of the total edge lengths relative to the minimum total length of edge in an area and quantifies the complexity or irregularity of the shape of a landscape. A higher Landscape shape index value indicates a more irregular or complex landscape shape, while a lower Landscape shape index value indicates a more compact landscape shape which is less heterogeneous.

Largest Patch Index is the area of the largest patch in a landscape relative to the area of the whole landscape. A larger largest patch index indicates dominance of a single patch of a landscape.

Patch Richness is a the number of different patches within a landscape. It provides a simple yet informative measure of landscape heterogeneity, as higher values of patch richness indicate a more heterogeneous landscape, while a lower patch richness highlights a more homogenous landscape.

Task 6: Plotting Landscape metrics

Task 6.1 For each metric, graph using a bar graph (metric on the Y-axis, landscape on the X-axis); your plots will have two, one for each landscape (4 pts).

land1<- raster("data/pre_fire.grd")
## Warning in .rasterFromRasterFile(grdfile, band = band, objecttype, ...): NAs
## introduced by coercion
land1_mets <-calculate_lsm(land1, 
                           what = c("lsm_l_contag", #Contagion
                                    "lsm_l_pd", #Patch density
                                    "lsm_l_ed", #Edge density
                                    "lsm_l_lsi", #landscape shape index
                                    "lsm_l_lpi", #Largest patch index
                                    "lsm_l_pr"), #Patch richness
                           directions = 8)
land1_mets$metric<- c("Contagion", "Edge density", "Largest patch index", "landscape shape index", "Patch density", "Patch richness")
land1_mets$layer <- "pre" #This gives the layer a name associated with the landscape so we can bind them!
land1_mets$layer <- factor(land1_mets$layer, levels = c("pre", "post")) # This orders the data so pre-fire data is displayed first in our plots

land2<- raster("data/post_fire.grd")
## Warning in .rasterFromRasterFile(grdfile, band = band, objecttype, ...): NAs
## introduced by coercion
land2_mets <-calculate_lsm(land2, 
                           what = c("lsm_l_contag", #Contagion
                                    "lsm_l_pd", #Patch density
                                    "lsm_l_ed", #Edge density
                                    "lsm_l_lsi", #landscape shape index
                                    "lsm_l_lpi", #Largest patch index
                                    "lsm_l_pr"), #Patch richness
                           directions = 8)
land2_mets$metric<- c("Contagion", "Edge density", "Largest patch index", "landscape shape index", "Patch density", "Patch richness")
land2_mets$layer <- "post" #This gives the layer a name associated with the landscape so we can bind them!
land2_mets$layer <- factor(land2_mets$layer, levels = c("pre", "post")) # This orders the data so pre-fire data is displayed first in our plots

land1_mets
## # A tibble: 6 × 6
##   layer level     class    id metric                value
##   <fct> <chr>     <int> <int> <chr>                 <dbl>
## 1 pre   landscape    NA    NA Contagion             58.2 
## 2 pre   landscape    NA    NA Edge density          26.3 
## 3 pre   landscape    NA    NA Largest patch index   50.8 
## 4 pre   landscape    NA    NA landscape shape index 27.7 
## 5 pre   landscape    NA    NA Patch density          1.23
## 6 pre   landscape    NA    NA Patch richness         7
land2_mets
## # A tibble: 6 × 6
##   layer level     class    id metric                value
##   <fct> <chr>     <int> <int> <chr>                 <dbl>
## 1 post  landscape    NA    NA Contagion             49.6 
## 2 post  landscape    NA    NA Edge density          32.4 
## 3 post  landscape    NA    NA Largest patch index   50.8 
## 4 post  landscape    NA    NA landscape shape index 33.7 
## 5 post  landscape    NA    NA Patch density          2.40
## 6 post  landscape    NA    NA Patch richness         7
allmetrics <- list(land1_mets, land2_mets) #This creates a list of the data tables
metric_table <- do.call(rbind, allmetrics) #This binds the tables together
p <- ggplot(data = metric_table, mapping = aes(x = as.factor(layer), y = value, fill = layer))
p + geom_bar(stat = "identity") + 
  facet_wrap(~metric, scales = "free") +
  xlab("Landscape") +
  ggtitle("Landscape level metrics for the pre- and post-fire landscapes")

Question 6.2 Which of the landscapes is the most fragmented, and which appears least fragmented? How did you determine this? (3 pts)

The landscape which is the most fragmented is the post fire landscape. I determined this by using a range of metrics such as the patch densit and the edge density which portray the composition of the patches of the landscape.

Patch Density and Edge Density are the metrics that best describe a landscape as being the most fragmented. The post fire landscape has the higher patch density which implies that it has more patches and is more fragmented. The post fire landscape has the higher edge density which implies that it has more edges and smaller patches thus is more fragmented.

The post fire landscape also has a lower contagion value thus is more well mixed across the landscape and patches are more likely to be distanced from eachother.

The metric that would likely indicate the least fragmented landscape is “Largest Patch Index.” Both pre and post settlement have similar largest patch index scores thus it is difficult to judge the degree of fragmentation based on this metric alone.

Question 6.3 : How would the correlation among landscape metrics influence your choice of what to report in an analysis that describes landscape pattern? (3 pts)

It is important to pick the correlations which are the highest or more significant among a plethora of available lanscape metrics. Including every single metric can be detrimental to report the changes in landscape patterns as some metrics can indicate similar findings and become redundant or even worse, can contradict eachother for different land cover types or the overall landscape.

Of the 6 different metrics, they can be grouped based on what they are reporting/indicating: The Largest patch index is a good metric to get an idea of the dominance of a single patch of a land cover type.

contagion and landscape shape index give an idea of the complexity of the landscape and how the land cover types are arranged.

patch richness, patch density and edge density give an idea of the number of patches and can be a good measure of fragmentation of the landscape.

Looking at how some metrics can give similar perspectives of the same landscape feature/characteristic it proves that it is inefficient to simultaneously analyse a the whole range of metrics at once.

Task 7 - Landscape Change Over Time

Task 7.1 Generate bar graphs for these class metrics (4 pts): 1. Patch Density 2. Edge Density 3. Landscape Shape Index 4. Largest Patch Index

Hint You can use the code from previous questions to calculate your metrics and put together your table.

land1<- raster("data/pre_fire.grd")
## Warning in .rasterFromRasterFile(grdfile, band = band, objecttype, ...): NAs
## introduced by coercion
land1_mets <-calculate_lsm(land1, 
                           what = c("lsm_c_pd", #Patch density
                                    "lsm_c_ed", #Edge density
                                    "lsm_c_lsi", #landscape shape index
                                    "lsm_c_lpi" #Largest patch index
                                    ),
                           directions = 8)
land1_mets$layer <- "pre" #This gives the layer a name associated with the landscape so we can bind them!
land1_mets$layer <- factor(land1_mets$layer, levels = c("pre", "post")) # This orders the data so pre-fire data is displayed first in our plots

land2<- raster("data/post_fire.grd")
## Warning in .rasterFromRasterFile(grdfile, band = band, objecttype, ...): NAs
## introduced by coercion
land2_mets <-calculate_lsm(land2, 
                           what = c("lsm_c_pd", #Patch density
                                    "lsm_c_ed", #Edge density
                                    "lsm_c_lsi", #landscape shape index
                                    "lsm_c_lpi" #Largest patch index
                                    ),
                           directions = 8)
land2_mets$layer <- "post" #This gives the layer a name associated with the landscape so we can bind them!
land2_mets$layer <- factor(land2_mets$layer, levels = c("pre", "post")) # This orders the data so pre-fire data is displayed first in our plots

allmetrics <- list(land1_mets, land2_mets) #This creates a list of the data tables
metric_table <- do.call(rbind, allmetrics) #This binds the tables together
allmetrics
## [[1]]
## # A tibble: 28 × 6
##    layer level class    id metric   value
##    <fct> <chr> <int> <int> <chr>    <dbl>
##  1 pre   class     1    NA ed      3.10  
##  2 pre   class     2    NA ed     18.9   
##  3 pre   class     3    NA ed      0.205 
##  4 pre   class     4    NA ed      2.32  
##  5 pre   class     5    NA ed     14.6   
##  6 pre   class     6    NA ed     12.8   
##  7 pre   class     7    NA ed      0.562 
##  8 pre   class     1    NA lpi     0.0642
##  9 pre   class     2    NA lpi    15.9   
## 10 pre   class     3    NA lpi     0.0178
## # ℹ 18 more rows
## 
## [[2]]
## # A tibble: 28 × 6
##    layer level class    id metric   value
##    <fct> <chr> <int> <int> <chr>    <dbl>
##  1 post  class     1    NA ed     15.7   
##  2 post  class     2    NA ed     11.0   
##  3 post  class     3    NA ed      1.23  
##  4 post  class     4    NA ed      9.41  
##  5 post  class     5    NA ed     14.2   
##  6 post  class     6    NA ed     12.8   
##  7 post  class     7    NA ed      0.562 
##  8 post  class     1    NA lpi     5.73  
##  9 post  class     2    NA lpi     3.23  
## 10 post  class     3    NA lpi     0.0704
## # ℹ 18 more rows
p <- ggplot(data = metric_table, mapping = aes(fill = layer, x = factor(class), y = value))
p + geom_bar(position = "dodge", stat = "identity") +
  facet_wrap(~metric, scales = "free") +
  xlab("Class") +
  scale_fill_grey() +
  ggtitle("Landscape change - before and after fire")

metric_table_wide <- tidyr::spread(metric_table, layer, value)
metric_table_wide <- metric_table_wide %>%
  mutate(percent_change = (post-pre)/pre)

metric_table_wide
## # A tibble: 28 × 7
##    level class    id metric     pre    post percent_change
##    <chr> <int> <int> <chr>    <dbl>   <dbl>          <dbl>
##  1 class     1    NA ed      3.10   15.7            4.06  
##  2 class     1    NA lpi     0.0642  5.73          88.3   
##  3 class     1    NA lsi    24.8    34.2            0.382 
##  4 class     1    NA pd      0.269   0.490          0.824 
##  5 class     2    NA ed     18.9    11.0           -0.417 
##  6 class     2    NA lpi    15.9     3.23          -0.797 
##  7 class     2    NA lsi    34.2    32.5           -0.0473
##  8 class     2    NA pd      0.287   0.417          0.455 
##  9 class     3    NA ed      0.205   1.23           5     
## 10 class     3    NA lpi     0.0178  0.0704         2.96  
## # ℹ 18 more rows

Question 7.2 : Based on the metrics how would you describe the change in the structure of each land cover class over time? (8 pts)

Edge Density Classes that increase: 3 (class 1,3,4) Classes that decrease: 2 (class 2,5) Classes that remain constant: 2 (class 6,7)

Largest Patch Index Classes that increase: 2 (class 1,4) Classes that decrease: 2 (class 2,5) Classes that remain constant: 3 (class 3, 6,7)

Landscape Shape Index Classes that increase: 4 (class 1,3,4,5) Classes that decrease: 1 (class 2) Classes that remain constant: 2 (class 6,7)

Patch Density Classes that increase: 5 (class 1,2,3,4,5) Classes that decrease:0 Classes that remain constant: 2 (class 6,7)

By looking at these 4 metrics, generally speaking,for most of the land cover classes, fire has increased their patch density and edge density, increased the landscape shape index and complexity of the land covers, and finally not had a large effect but a slight overall decrease on the single largest patch of some land covers. Thus the structure of each class has become more patchy after fire, with an overall increase in number of patches and decrease in habitat complexity thus in general the classes have become more fragmented.

An individualized analysis of land cover classes: Class 1: Its edge density greatly increases more than tripling, largest patch index greatly increases, landscape shape index increases, and patch density greatly increases nearly doubling. Based on these metrics, class 1 has become more patchy also known as fragmented, particularly due to a higher edge density and higher patch density.

Class 2: Its edge density greatly decreases by nearly 50%, largest patch index greatly decreases by over 50%, landscape shape index slightly decreases, and patch density increases. An increase in patch density, a massive decrease in its largest patch and landscape complexity decreasing, it can be assumed that class two has also become more fragmented, regarless of a decrease in edge density.

Class 3: Its edge density increases, largest patch index remains constant, landscape shape index drastically increases, and patch density increases massively. Based on these metrics, class 3 has become more patchy also known as fragmented, particularly due to a higher edge density and higher patch density.

Class 4: Its edge density increases by a factor of 3, largest patch index slightly increases, landscape shape index increases by more than double, and patch density increases by over a factor of 4. Based on these metrics, class 4 has become more patchy also known as fragmented, particularly due to a massive increase in edge density and higher patch density.

Class 5: Its edge density slightly decreases, largest patch index slightly decreases, landscape shape index increases, and patch density increases. Based on these metrics it is hard ot come to a conclusion about the change in structure of class 5. It has potentially become more fragmented due to an increase in patch density and reduction in its largest patch, but it is hard to say with minimal changes to the compostion.

Class 6: Its edge density remains constant, largest patch index remains constant, landscape shape index remains constant, and patch density remains constant. When looking at these 4 metrics, the structure of this land cover class is unaffected by fire and the composition of class 6 remains constant.

Class 7: Its edge density remains constant, largest patch index remains constant, landscape shape index remains constant, and patch density remains constant. When looking at these 4 metrics, the structure of this land cover class is unaffected by fire and the composition of class 7 remains constant.

The metric that would likely indicate the least fragmented landscape is “Largest Patch Index.” Both pre and post settlement have similar largest patch index scores thus it is difficult to judge the degree of fragmentation based on this metric alone.