-
Notifications
You must be signed in to change notification settings - Fork 0
/
04-application.Rmd
233 lines (206 loc) · 10.7 KB
/
04-application.Rmd
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# Analysis by EcoRegion
## EcoRegions by elevation
![EcoRegions within the St. Vrain Watershed](ecoregions drawn.png)
I want to break out my data by these EcoRegions. To do this I have determined the approximate, average elevation at each boundary. I mutate the table to give me an "ecoregions" column:
```{r table with ecoregions, eval=TRUE, echo=TRUE}
reach_attributes %>%
filter(InNetwork == 1 & MaxElevSmo > 0) %>%
mutate(max_elev = MaxElevSmo/100) %>%
mutate(min_elev = MInElevSmo/100) %>%
mutate(ecoregion = case_when(max_elev > 3048 ~ "Alpine",
max_elev <= 3048 & max_elev > 2804 ~ "Subalpine Forest",
max_elev <= 2804 & max_elev > 2072 ~ "Mid-Elevation Forest",
max_elev <= 2072 & max_elev > 1706 ~ "Foothill Shrub",
max_elev <=1706 & max_elev > 1524 ~ "Front Range Fans",
max_elev <= 1524 ~ "Plains")) %>%
select(FID, max_elev, ecoregion) %>%
slice_sample(n=10) %>%
knitr::kable(align = "c")
```
### Slope vs. Bankfull width
How do slope and bankfull width relate? I have filtered out slopes less than 0 and greater than 9 to reduce the noise.
```{r ggridges graph, eval=TRUE, echo=TRUE}
reach_attributes %>%
filter(InNetwork == 1 & MaxElevSmo > 0 & Slope > 0 & Slope < 9) %>%
mutate(max_elev = MaxElevSmo/100) %>%
mutate(min_elev = MInElevSmo/100) %>%
mutate(ecoregion = case_when(max_elev > 3048 ~ "Alpine",
max_elev <= 3048 & max_elev > 2804 ~ "Subalpine Forest",
max_elev <= 2804 & max_elev > 2072 ~ "Mid-Elevation Forest",
max_elev <= 2072 & max_elev > 1706 ~ "Foothill Shrub",
max_elev <=1706 & max_elev > 1524 ~ "Front Range Fans",
max_elev <= 1524 ~ "Plains")) %>%
ggplot(aes(x = BFwidth, y = Slope, color = ecoregion)) +
geom_point() +
scale_fill_viridis_d() +
theme_minimal() +
labs(y = "Slope", x = "Bankfull width (m)", color = "EcoRegion") +
theme(legend.position = "bottom")
```
It doesn't make a lot of sense for a river to suddenly jump from a bankfull width of ~ 24 ft to ~46 ft. This could be due to the fact that many of the reaches in the urbanized and heavily manipulated lower regions of the watershed are considered "out of network" and therefore have been filtered out. For the purposes of this project, I further filter out those largest bankfull widths:
```{r less bf, eval=TRUE, echo=TRUE}
reach_attributes %>%
filter(InNetwork == 1 & MaxElevSmo > 0 &
Slope > 0 & Slope < 9
& BFwidth < 25) %>%
mutate(max_elev = MaxElevSmo/100) %>%
mutate(min_elev = MInElevSmo/100) %>%
mutate(ecoregion = case_when(max_elev > 3048 ~ "Alpine",
max_elev <= 3048 & max_elev > 2804 ~ "Subalpine Forest",
max_elev <= 2804 & max_elev > 2072 ~ "Mid-Elevation Forest",
max_elev <= 2072 & max_elev > 1706 ~ "Foothill Shrub",
max_elev <=1706 & max_elev > 1524 ~ "Front Range Fans",
max_elev <= 1524 ~ "Plains")) %>%
ggplot(aes(x = BFwidth, y = Slope, color = ecoregion)) +
geom_point() +
scale_fill_viridis_d() +
theme_minimal() +
labs(y = "Slope", x = "Bankfull width (m)", color = "EcoRegion") +
theme(legend.position = "bottom")
```
Though they are different colors, it is kind of hard to tell what is going on between the ecoregions, so I am going to pull each region out into its own plot:
```{r alpine, eval=TRUE, echo=TRUE}
reach_attributes %>%
filter(InNetwork == 1 & MaxElevSmo > 0 &
Slope > 0 & Slope < 9
& BFwidth < 25) %>%
mutate(max_elev = MaxElevSmo/100) %>%
mutate(min_elev = MInElevSmo/100) %>%
mutate(ecoregion = case_when(max_elev > 3048 ~ "Alpine",
max_elev <= 3048 & max_elev > 2804 ~ "Subalpine Forest",
max_elev <= 2804 & max_elev > 2072 ~ "Mid-Elevation Forest",
max_elev <= 2072 & max_elev > 1706 ~ "Foothill Shrub",
max_elev <=1706 & max_elev > 1524 ~ "Front Range Fans",
max_elev <= 1524 ~ "Plains")) %>%
filter(ecoregion == "Alpine") %>%
ggplot(aes(x = BFwidth, y = Slope, color = ecoregion)) +
geom_point() +
scale_fill_viridis_d() +
theme_minimal() +
labs(title = "Alpine", y = "Slope", x = "Bankfull width (m)", color = "EcoRegion") +
theme(legend.position = "none")
```
I'll do this for the rest of the ecoregions and then stack the plots:
```{r all regions, eval=TRUE, echo=TRUE, warning=FALSE}
alp <- reach_attributes %>%
filter(InNetwork == 1 & MaxElevSmo > 0 &
Slope > 0 & Slope < 9
& BFwidth < 25) %>%
mutate(max_elev = MaxElevSmo/100) %>%
mutate(min_elev = MInElevSmo/100) %>%
mutate(ecoregion = case_when(max_elev > 3048 ~ "Alpine",
max_elev <= 3048 & max_elev > 2804 ~ "Subalpine Forest",
max_elev <= 2804 & max_elev > 2072 ~ "Mid-Elevation Forest",
max_elev <= 2072 & max_elev > 1706 ~ "Foothill Shrub",
max_elev <=1706 & max_elev > 1524 ~ "Front Range Fans",
max_elev <= 1524 ~ "Plains")) %>%
filter(ecoregion == "Alpine") %>%
ggplot(aes(x = BFwidth, y = Slope, color = ecoregion)) +
geom_point() +
xlim(0, 25) + ylim(0, 1.5) +
scale_fill_viridis_d() +
theme_minimal() +
labs(title = "Alpine", y = "Slope", x = "Bankfull width (m)", color = "EcoRegion") +
theme(legend.position = "none")
saf <- reach_attributes %>%
filter(InNetwork == 1 & MaxElevSmo > 0 &
Slope > 0 & Slope < 9
& BFwidth < 25) %>%
mutate(max_elev = MaxElevSmo/100) %>%
mutate(min_elev = MInElevSmo/100) %>%
mutate(ecoregion = case_when(max_elev > 3048 ~ "Alpine",
max_elev <= 3048 & max_elev > 2804 ~ "Subalpine Forest",
max_elev <= 2804 & max_elev > 2072 ~ "Mid-Elevation Forest",
max_elev <= 2072 & max_elev > 1706 ~ "Foothill Shrub",
max_elev <=1706 & max_elev > 1524 ~ "Front Range Fans",
max_elev <= 1524 ~ "Plains")) %>%
filter(ecoregion == "Subalpine Forest") %>%
ggplot(aes(x = BFwidth, y = Slope, color = ecoregion)) +
geom_point() +
xlim(0, 25) + ylim(0, 1.5) +
scale_fill_viridis_d() +
theme_minimal() +
labs(title = "Subalpine Forest", y = "Slope", x = "Bankfull width (m)", color = "EcoRegion") +
theme(legend.position = "none")
mef <- reach_attributes %>%
filter(InNetwork == 1 & MaxElevSmo > 0 &
Slope > 0 & Slope < 9
& BFwidth < 25) %>%
mutate(max_elev = MaxElevSmo/100) %>%
mutate(min_elev = MInElevSmo/100) %>%
mutate(ecoregion = case_when(max_elev > 3048 ~ "Alpine",
max_elev <= 3048 & max_elev > 2804 ~ "Subalpine Forest",
max_elev <= 2804 & max_elev > 2072 ~ "Mid-Elevation Forest",
max_elev <= 2072 & max_elev > 1706 ~ "Foothill Shrub",
max_elev <=1706 & max_elev > 1524 ~ "Front Range Fans",
max_elev <= 1524 ~ "Plains")) %>%
filter(ecoregion == "Mid-Elevation Forest") %>%
ggplot(aes(x = BFwidth, y = Slope, color = ecoregion)) +
geom_point() +
xlim(0, 25) + ylim(0, 1.5) +
scale_fill_viridis_d() +
theme_minimal() +
labs(title = "Mid-Elevation Forest", y = "Slope", x = "Bankfull width (m)", color = "EcoRegion") +
theme(legend.position = "none")
fs <- reach_attributes %>%
filter(InNetwork == 1 & MaxElevSmo > 0 &
Slope > 0 & Slope < 9
& BFwidth < 25) %>%
mutate(max_elev = MaxElevSmo/100) %>%
mutate(min_elev = MInElevSmo/100) %>%
mutate(ecoregion = case_when(max_elev > 3048 ~ "Alpine",
max_elev <= 3048 & max_elev > 2804 ~ "Subalpine Forest",
max_elev <= 2804 & max_elev > 2072 ~ "Mid-Elevation Forest",
max_elev <= 2072 & max_elev > 1706 ~ "Foothill Shrub",
max_elev <=1706 & max_elev > 1524 ~ "Front Range Fans",
max_elev <= 1524 ~ "Plains")) %>%
filter(ecoregion == "Foothill Shrub") %>%
ggplot(aes(x = BFwidth, y = Slope, color = ecoregion)) +
geom_point() +
xlim(0, 25) + ylim(0, 1.5) +
scale_fill_viridis_d() +
theme_minimal() +
labs(title = "Foothill Shrub", y = "Slope", x = "Bankfull width (m)", color = "EcoRegion") +
theme(legend.position = "none")
frf <- reach_attributes %>%
filter(InNetwork == 1 & MaxElevSmo > 0 &
Slope > 0 & Slope < 9
& BFwidth < 25) %>%
mutate(max_elev = MaxElevSmo/100) %>%
mutate(min_elev = MInElevSmo/100) %>%
mutate(ecoregion = case_when(max_elev > 3048 ~ "Alpine",
max_elev <= 3048 & max_elev > 2804 ~ "Subalpine Forest",
max_elev <= 2804 & max_elev > 2072 ~ "Mid-Elevation Forest",
max_elev <= 2072 & max_elev > 1706 ~ "Foothill Shrub",
max_elev <=1706 & max_elev > 1524 ~ "Front Range Fans",
max_elev <= 1524 ~ "Plains")) %>%
filter(ecoregion == "Front Range Fans") %>%
ggplot(aes(x = BFwidth, y = Slope, color = ecoregion)) +
geom_point() +
xlim(0, 25) + ylim(0, 1.5) +
scale_fill_viridis_d() +
theme_minimal() +
labs(title = "Front Range Fans", y = "Slope", x = "Bankfull width (m)", color = "EcoRegion") +
theme(legend.position = "none")
plns <- reach_attributes %>%
filter(InNetwork == 1 & MaxElevSmo > 0 &
Slope > 0 & Slope < 9
& BFwidth < 25) %>%
mutate(max_elev = MaxElevSmo/100) %>%
mutate(min_elev = MInElevSmo/100) %>%
mutate(ecoregion = case_when(max_elev > 3048 ~ "Alpine",
max_elev <= 3048 & max_elev > 2804 ~ "Subalpine Forest",
max_elev <= 2804 & max_elev > 2072 ~ "Mid-Elevation Forest",
max_elev <= 2072 & max_elev > 1706 ~ "Foothill Shrub",
max_elev <=1706 & max_elev > 1524 ~ "Front Range Fans",
max_elev <= 1524 ~ "Plains")) %>%
filter(ecoregion == "Plains") %>%
ggplot(aes(x = BFwidth, y = Slope, color = ecoregion)) +
geom_point() +
xlim(0, 25) + ylim(0, 1.5) +
scale_fill_viridis_d() +
theme_minimal() +
labs(title = "Plains", y = "Slope", x = "Bankfull width (m)", color = "EcoRegion") +
theme(legend.position = "none")
(alp|saf)/(mef|fs)/(frf|plns)
```