knitr::opts_chunk$set(echo = FALSE, fig.height = 3, fig.width = 7, fig.align = "center")
library(dplyr)
library(ggplot2)
library(xgboost)
library(knitr)
library(plotly)
library(caret)
library(kableExtra)
setwd("C:/Users/user/OneDrive/ABMI/R_scripts")
### Import data
d <- read.csv("trainPoints_pilot_1.csv")
d <- as.data.frame(d)
d <- subset (d, select = -c(system.index, MSK_CLDPRB, MSK_CLDPRB_1, MSK_SNWPRB, MSK_SNWPRB_1,
OBJECTID, QA60, QA60_1, SCL, SCL_1,
cloudScore, cloudScore_1, probability, probability_1,
waterVapor, waterVapor_1, .geo))
d <- na.omit(d)
Analysis of variables from training samples used for a pilot area in the boreal region of Alberta.
Study Area: Boreal Pilot Area, 3.7 million hectares in northern Alberta north of Athabasca, east of Slave Lake, and south of Fort McMurray
Training Data: 12,672 random points from interpreted photo 3 by 7 km photo-plots distributed across study area
Spectral Data: - Sentinel-1 Summer 2021 and Winter 2020-2021 mean composites and derived indices - Sentinel-2 Summer 2019-2021 and Autumn 2019-2021 mean composites and derived indices - Compiled in Google Earth Engine
Pixel Based Sampling performed in Google Earth Engine and exported as csv.
## Summary of the number of points of each class
summary <- d %>% group_by(Class2) %>% summarize(n())
kable(summary) %>% kable_styling(bootstrap_options = "striped", font_size = 14)| Class2 | n() |
|---|---|
| ag | 249 |
| conifer | 4989 |
| decid | 4783 |
| grass | 681 |
| imperv | 10 |
| mixedwood | 1305 |
| shrub | 396 |
| water | 259 |
## Violin plots - SAR variables
RSvars <- c("VH_Summer", "VH_Winter", "deltaVH",
"VV_Summer", "VV_Winter", "deltaVV",
"DPOL_Summer", "DPOL_Winter", "deltaDPOL",
"DPSVI_Summer", "DPSVI_Winter", "deltaDPSVI"
)
for (i in 1:length(RSvars)){
var <- RSvars[i]
print(
ggplot(d, aes_string(x = "Class2", y = var, fill = "Class2")) +
geom_violin() +
scale_fill_manual(name = "", values=c('red', 'darkgreen', 'orange', 'yellow', 'grey', "green", "purple", "blue")) +
xlab("Class2")+
labs(title = (var))
)
}
## Violin plots - S2 Bands -Summer
RSvars <- c("blue", "green", "red", "re1", "re2", "re3", "nir", "nir2", "swir1", "swir2"
)
for (i in 1:length(RSvars)){
var <- RSvars[i]
print(
ggplot(d, aes_string(x = "Class2", y = var, fill = "Class2")) +
geom_violin() +
scale_fill_manual(name = "", values=c('red', 'darkgreen', 'orange', 'yellow', 'grey', "green", "purple", "blue")) +
xlab("Class2")+
labs(title = paste("Summer ", toupper(var)))
)
}
RSvars <- c("blue_1", "green_1", "red_1", "re1_1", "re2_1", "re3_1", "nir_1", "nir2_1", "swir1_1", "swir2_1"
)
for (i in 1:length(RSvars)){
var <- RSvars[i]
print(
ggplot(d, aes_string(x = "Class2", y = var, fill = "Class2")) +
geom_violin() +
scale_fill_manual(name = "", values=c('red', 'darkgreen', 'orange', 'yellow', 'grey', "green", "purple", "blue")) +
xlab("Class2")+
labs(title = paste("Autumn ", toupper(var)))
)
}
bands <- list ("blue", "green", "red", "re1", "re2", "re3", "nir", "nir2","swir1", "swir2")
for (b in bands) {
d[,paste0("diff", b, sep = "")]<- d[,paste0(b, sep = "")]-d[,paste0( b, "_1", sep = "")]
}
## Violin plots - S2 Band Differences
RSvars <- c("diffblue", "diffgreen", "diffred", "diffre1", "diffre2",
"diffre3", "diffnir", "diffnir2", "diffswir1", "diffswir2"
)
for (i in 1:length(RSvars)){
var <- RSvars[i]
print(
ggplot(d, aes_string(x = "Class2", y = var, fill = "Class2")) +
geom_violin() +
xlab("Class2")+
scale_fill_manual(name = "", values=c('red', 'darkgreen', 'orange', 'yellow', 'grey', "green", "purple", "blue")) +
labs(title = paste("Seasonal Difference ", toupper(substring(var,first = 5))))
)
}
## Violin plots - Optical indices - Summer
RSvars <- c("NDVI", "NDVI705", "NDWI", "NDWI2", "NBR", "nARI",
"REIP", "IRECI"
)
for (i in 1:length(RSvars)){
var <- RSvars[i]
print(
ggplot(d, aes_string(x = "Class2", y = var, fill = "Class2")) +
geom_violin() +
scale_fill_manual(name = "", values=c('red', 'darkgreen', 'orange', 'yellow', 'grey', "green", "purple", "blue")) +
xlab("Class2")+
labs(title = (var))+
labs(title = paste("Summer ", var))
)
}
## Violin plots - Optical indices - Autumn
RSvars <- c("NDVI_1", "NDVI705_1", "NDWI_1", "NDWI2_1", "NBR_1", "nARI_1",
"REIP_1", "IRECI_1"
)
for (i in 1:length(RSvars)){
var <- RSvars[i]
print(
ggplot(d, aes_string(x = "Class2", y = var, fill = "Class2")) +
geom_violin() +
scale_fill_manual(name = "", values=c('red', 'darkgreen', 'orange', 'yellow', 'grey', "green", "purple", "blue")) +
xlab("Class2")+
labs(title = (var))+
labs(title = paste("Autumn ", var))
)
}
## Differences in Optical indices
bands <- list ("NDVI", "NDVI705", "NDWI", "NDWI2", "NBR", "nARI",
"REIP", "IRECI")
for (b in bands) {
d[,paste0("diff", b, sep = "")]<- d[,paste0(b, sep = "")]-d[,paste0( b, "_1", sep = "")]
}
RSvars <- c("diffNDVI", "diffNDVI705", "diffNDWI", "diffNDWI2", "diffNBR", "diffnARI",
"diffREIP", "diffIRECI"
)
for (i in 1:length(RSvars)){
var <- RSvars[i]
print(
ggplot(d, aes_string(x = "Class2", y = var, fill = "Class2")) +
geom_violin() +
xlab("Class2")+
scale_fill_manual(name = "", values=c('red', 'darkgreen', 'orange', 'yellow', 'grey', "green", "purple", "blue")) +
labs(title = paste("Seasonal Difference ", substring(var,first = 5)))
)
}
# Topo Indices
RSvars <- c("SWI", "TPI250", "TPI500", "TPI750", "TRI", "VBF")
for (i in 1:length(RSvars)){
var <- RSvars[i]
print(
ggplot(d, aes_string(x = "Class2", y = var, fill = "Class2")) +
geom_violin() +
xlab("Class2")+scale_fill_manual(name = "", values=c('red', 'darkgreen', 'orange', 'yellow', 'grey', "green", "purple", "blue")) +
labs(title = (var))
)
}