-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomparing.qmd
157 lines (118 loc) · 4.82 KB
/
comparing.qmd
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
---
title: "Comparisons"
---
```{r include=FALSE, echo=FALSE, message=FALSE, warning=FALSE}
library(chorddiag)
library(htmlwidgets)
library(igraph)
library(readr)
library(tidygraph)
library(tidyverse)
```
Outputs on this page compare "Past" conditions with "Present" conditions. Results here are intended for exploration and illumination of issues to explore further. As noted on the "Present" page there are differences in the classification scheme so direct comparisons should be viewed with caution.
## Summary
## Looking at broad changes, vegetation conversion
This interactive 'chord' diagram allows you to explore changes on the landscape. To use:
* Hover over the outer bands to see connections. For example, if you over over the dark green outer band of the "Past Conifer" group you can see that some is now mapped as converted, some hardwood, etc., and that the majority is still mapped as conifer.
* Alternatively, if you hover over the orange outer band of "Hardwood" you can see what the present extent of hardwoods vegetation was historically.
* The popups contain acres for the band.
```{r chord, echo=FALSE, message=FALSE, warning=FALSE, include=FALSE}
# read in data
chord_df<- read_csv("data/bps2evt_chord.csv")
#view(histFireGVchord)
#convert to matrix
matrix_df <-as.matrix(as_adjacency_matrix(as_tbl_graph(chord_df),attr = "ACRES"))
#clean up matrix (could be cleaner!)
matrix_df = subset(matrix_df, select = -c(1:6))
matrix_df <- matrix_df[-c(7:15),]
#make a custom color pallet #eb4034 (redish) #b0af9e(grey)
# ORIGINAL
groupColors <-c( "#1d4220", # conifer
"#fc9d03", # grassland
"#56bf5f", # hardwood
"#397d3f", # hardwood-conifer
"#7db7c7", # riparian
"#6e4f1e", # shrubland
"#f5e942", # cur ag
"#1d4220", # cur conifer
"#397d3f", # cur hdw-con
"#b0af9e", # developed
"#eb4034", # exotics
"#fc9d03", # grassland
"#56bf5f", # hardwood
"#7db7c7",
"#6e4f1e"# shrubland
)
#make chord diagram
chord<-chorddiag(data = matrix_df,
type = "bipartite",
groupColors = groupColors,
groupnamePadding = 10,
groupPadding = 3,
groupnameFontsize = 11 ,
showTicks = FALSE,
margin=150,
tooltipGroupConnector = " ▶ ",
chordedgeColor = "#363533"
)
chord
#save then print to have white background
htmlwidgets::saveWidget(chord,
"chord.html",
background = "white",
selfcontained = TRUE
)
```
<iframe src="chord.html" height="720" width="720" style="border: 1px solid #464646;" allowfullscreen="" allow="autoplay" data-external=".5"></iframe>
<br>
## Succession classes for most dominant Biophysical Settings
```{r scls chart, echo=FALSE, message=FALSE, warning=FALSE, fig.width=10, fig.height=9}
BPS_SCLS2 <- read.csv("data/bpsScls2.csv")
bps_scls_3 <- BPS_SCLS2 %>%
group_by(Var1) %>%
mutate(total.count = sum(Freq)) %>%
ungroup() %>%
dplyr::filter(dense_rank(desc(total.count)) < 7) %>%
dplyr::select(c("BpS_Name", "refLabel", "currentPercent", "refPercent")) %>%
pivot_longer(
cols = c(`refPercent`, `currentPercent`),
names_to = "refCur",
values_to = "Percent"
)
# order classes
bps_scls_3$refLabel <- factor(bps_scls_3$refLabel, levels= c(
"Developed",
"Agriculture",
"UE",
"UN",
"E",
"D",
"C",
"B",
"A"))
sclasplot <-
ggplot(bps_scls_3, aes(fill=factor(refCur), y=Percent, x=refLabel)) +
geom_col(width = 0.8, position = position_dodge()) +
coord_flip() +
facet_grid(. ~BpS) +
scale_x_discrete(limits = (levels(bps_scls_3$refLabel))) +
labs(
title = "Succession Classes past and present",
subtitle = "6 BpSs selected for illustration. Not all succession classes present in all BpSs",
caption = "\nData from landfire.gov.",
x = "",
y = "Percent")+
theme_minimal(base_size = 14)+
theme(plot.caption = element_text(hjust = 0, face= "italic"), #Default is hjust=1
plot.title.position = "plot", #NEW parameter. Apply for subtitle too.
plot.caption.position = "plot") +
scale_fill_manual(values = c("#3d4740", "#32a852" ), # present (grey), historical (green)
name = " ",
labels = c("Present",
"Past")) +
facet_wrap(~BpS_Name, nrow(3),labeller = labeller(BpS_Name = label_wrap_gen())) +
theme(panel.spacing = unit(.05, "lines"),
panel.border = element_rect(color = "black", fill = NA, size = 1),
strip.background = element_rect(color = "black", size = 1))
sclasplot
```