-
Notifications
You must be signed in to change notification settings - Fork 18
/
.Rhistory
77 lines (77 loc) · 2.8 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
install.packages("VGAM")
install.packages("igraph")
install.packages("poweRlaw")
require(viridis)
viridis
viridis()
install.packages("knitr")
library(ForestGapR)
require(devtools)
check()
library(ForestGapR)
require(ForestGapR)
?GapChangeDec
[Package ForestGapR version 0.1.7 Index]
# Loading terra and viridis libraries
library(terra)
library(viridis)
# ALS-derived CHM from Fazenda Cauxi - Brazilian tropical forest
data(ALS_CHM_CAU_2012)
data(ALS_CHM_CAU_2014)
# set height thresholds (e.g. 10 meters)
threshold <- 10
size <- c(1, 10^4) # m2
# Detecting forest gaps
gaps_cau2012 <- getForestGaps(chm_layer = ALS_CHM_CAU_2012, threshold = threshold, size = size)
gaps_cau2014 <- getForestGaps(chm_layer = ALS_CHM_CAU_2014, threshold = threshold, size = size)
# Detecting forest gaps changes
Gap_changes <- GapChangeDec(gap_layer1 = gaps_cau2012, gap_layer2 = gaps_cau2014)
# Plotting ALS-derived CHM and forest gaps
oldpar <- par(mfrow = c(1, 3))
plot(ALS_CHM_CAU_2012, main = "Forest Canopy Gap - 2012", col = viridis(10))
plot(gaps_cau2012, add = TRUE, col = "red", legend = FALSE)
plot(ALS_CHM_CAU_2014, main = "Forest Canopy Gap - 2014", col = viridis(10))
plot(gaps_cau2014, add = TRUE, col = "red", legend = FALSE)
plot(ALS_CHM_CAU_2014, main = "Forest Gap Changes Detected", col = viridis(10))
plot(Gap_changes, add = TRUE, col = "orange", legend = FALSE)
par(oldpar)
3200000/20
require(ForestGapR)
# set height thresholds (e.g. 10 meters)
threshold <- 10
size <- c(1, 10^4) # m2
# Detecting forest gaps
gaps_duc <- getForestGaps(chm_layer = ALS_CHM_DUC, threshold = threshold, size = size)
# Ploting gaps
plot(gaps_duc, col = "red", add = TRUE, main = "Forest Canopy Gap", legend = FALSE)
# set the height thresholds
nthresholds <- c(10, 15, 20, 25)
size <- c(1, 10^4) # m2
# creating an empy vector to store multiple gaps as SpatRasters
gaps_stack <- c()
# Gap detection
for (i in nthresholds) {
gaps_i <- getForestGaps(chm_layer = ALS_CHM_DUC, threshold = i, size = size)
names(gaps_i) <- paste0("gaps_", i, "m")
gaps_stack <- c(gaps_stack, gaps_i)
}
# plot gaps
oldpar <- par(no.readonly = TRUE)
par(mfrow = c(2, 2))
plot(ALS_CHM_DUC, col = viridis(10), main = "Height threshold 10m")
plot(gaps_stack$gaps_10m, col = "red", add = TRUE, legend = FALSE)
plot(ALS_CHM_DUC, col = viridis(10), main = "Height threshold 15m")
plot(gaps_stack$gaps_15m, col = "red", add = TRUE, legend = FALSE)
plot(ALS_CHM_DUC, col = viridis(10), main = "Height threshold 20m")
plot(gaps_stack$gaps_20m, col = "red", add = TRUE, legend = FALSE)
plot(ALS_CHM_DUC, col = viridis(10), main = "Height threshold 25m")
plot(gaps_stack$gaps_25m, col = "red", add = TRUE, legend = FALSE)
par(oldpar)
require(usethis)
usethis::use_tidy_description()
usethis::use_package()
usethis::use_package("igraph")
igraph::fun()
usethis::use_package("igraph", "Suggests")
require(igraph)
86279*3