-
Notifications
You must be signed in to change notification settings - Fork 13
/
toha_lake_data_map.Rmd
215 lines (190 loc) · 8.18 KB
/
toha_lake_data_map.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
---
title: "Status of Lake Data for TOHA Modeling"
output: html_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE,
warning = FALSE,
message = FALSE)
```
```{r filterData, echo=FALSE}
library(sf)
library(dplyr)
lake_summary_sf <- readRDS(file.path("8_viz", "inout", "summary_toha_sf.rds"))
lake_summary_df <- lake_summary_sf
lake_summary_df$geometry <- NULL
# needs
lake_summary_df <- lake_summary_df %>%
filter(meteo)
lake_summary_df$popup <- paste0("<table>",
"<tr><td>Lake Name:</td><td>",
lake_summary_df$GNIS_Name,'</td></tr>',
"<tr><td>Site ID:</td><td>",
lake_summary_df$site_id,'</td></tr>',
"<tr><td># Temp Observations:</td><td>",
lake_summary_df$n_temp_obs,'</td></tr>',
"<tr><td># Profiles:</td><td>",
lake_summary_df$n_profiles,'</td></tr>',
"<tr><td>Crosswalked to:</td><td>",
lake_summary_df$Lake_Source,'</td></tr>',
"<tr><td># Walleye Yrs:</td><td>",
lake_summary_df$n_walleye_yrs,'</td></tr>',
"<tr><td>EWR Lake:</td><td>",
lake_summary_df$EWR_Lake,'</td></tr>',
'</table>')
lakes_w_zmax_hypso <- lake_summary_df %>%
filter(zmax,
hypsography)
# Essentially filters to MN since we only have kw for those
lakes_with_timevaryingkw <- lakes_w_zmax_hypso %>%
filter(has_time_varying_kw)
lakes_model_toha <- lakes_with_timevaryingkw %>%
filter(n_walleye_yrs >= 5)
lakes_gucci <- lakes_with_timevaryingkw %>%
filter(n_profiles >= 50)
lakes_timex <- lakes_with_timevaryingkw %>%
filter(n_profiles >= 10, n_profiles < 50)
lakes_gucci_walleye <- lakes_gucci %>%
filter(n_walleye_yrs >= 5)
lakes_timex_walleye <- lakes_timex %>%
filter(n_walleye_yrs >= 5)
lakes_ewr_pgdl_gucci <- lakes_with_timevaryingkw %>%
filter(n_profiles >= 50,
EWR_Lake)
lakes_ewr_pgdl_light <- lakes_with_timevaryingkw %>%
filter(n_profiles >= 10, n_profiles < 50,
EWR_Lake)
lakes_ewr_nokw_pgdl_gucci <- lake_summary_df %>%
filter(zmax,
hypsography,
n_profiles >= 50,
!has_time_varying_kw,
EWR_Lake)
lakes_ewr_nokw_pgdl_light <- lake_summary_df %>%
filter(zmax,
hypsography,
n_profiles >= 10, n_profiles < 50,
!has_time_varying_kw,
EWR_Lake)
```
```{r firstMap}
library(leaflet)
legend_vals <- c("< 10 profiles", "< 50 profiles", "50+ profiles", "none")
pal <- colorFactor(c("#35B779B3","#31688EB3","#440154B3",'red'), legend_vals)
groups <- c(
sprintf("Zmax & hypso (n=%s)", nrow(lakes_w_zmax_hypso)),
sprintf("Zmax, hypso, & time-varying kw (n=%s)", nrow(lakes_with_timevaryingkw)),
sprintf("TOHA model: zmax, hypso, time-varying kw, & walleye (n=%s)", nrow(lakes_model_toha)),
sprintf("PGDL gucci (n=%s)", nrow(lakes_gucci)),
sprintf("PGDL light (n=%s)", nrow(lakes_timex)),
sprintf("PGDL gucci w/ walleye (n=%s)", nrow(lakes_gucci_walleye)),
sprintf("PGDL light w/ walleye (n=%s)", nrow(lakes_timex_walleye)),
sprintf("EWR Lake: ready for PGDL gucci (n=%s)", nrow(lakes_ewr_pgdl_gucci)),
sprintf("EWR Lake: ready for PGDL light (n=%s)", nrow(lakes_ewr_pgdl_light)),
sprintf("EWR Lake: no Kw but temp for PGDL gucci (n=%s)", nrow(lakes_ewr_nokw_pgdl_gucci)),
sprintf("EWR Lake: no Kw but temp for PGDL light (n=%s)", nrow(lakes_ewr_nokw_pgdl_light))
)
leaflet::leaflet(height = "500px", width = "1000px") %>%
leaflet::addProviderTiles("CartoDB.Positron") %>%
leaflet::setView(lng = -92.5, lat = 46, zoom=6) %>%
leaflet::addCircleMarkers(data= lakes_w_zmax_hypso,
lat=~latitude, lng=~longitude,
group = groups[1],
popup= ~popup,
fillColor = ~pal(obs_category),
fillOpacity = 0.8,
radius = ~4,
stroke=FALSE) %>%
leaflet::addCircleMarkers(data= lakes_with_timevaryingkw,
lat=~latitude, lng=~longitude,
group = groups[2],
popup= ~popup ,
fillColor = ~pal(obs_category),
fillOpacity = 0.8,
radius = ~4,
stroke=FALSE) %>%
leaflet::addCircleMarkers(data= lakes_model_toha,
lat=~latitude, lng=~longitude,
group = groups[3],
popup= ~popup ,
fillColor = ~pal(obs_category),
fillOpacity = 0.8,
radius = ~4,
stroke=FALSE) %>%
leaflet::addCircleMarkers(data= lakes_gucci,
lat=~latitude, lng=~longitude,
group = groups[4],
popup= ~popup ,
fillColor = ~pal(obs_category),
fillOpacity = 0.8,
radius = ~4,
stroke=FALSE) %>%
leaflet::addCircleMarkers(data= lakes_timex,
lat=~latitude, lng=~longitude,
group = groups[5],
popup= ~popup ,
fillColor = ~pal(obs_category),
fillOpacity = 0.8,
radius = ~4,
stroke=FALSE) %>%
leaflet::addCircleMarkers(data= lakes_gucci_walleye,
lat=~latitude, lng=~longitude,
group = groups[6],
popup= ~popup ,
fillColor = ~pal(obs_category),
fillOpacity = 0.8,
radius = ~4,
stroke=FALSE) %>%
leaflet::addCircleMarkers(data= lakes_timex_walleye,
lat=~latitude, lng=~longitude,
group = groups[7],
popup= ~popup ,
fillColor = ~pal(obs_category),
fillOpacity = 0.8,
radius = ~4,
stroke=FALSE) %>%
leaflet::addCircleMarkers(data= lakes_ewr_pgdl_gucci,
lat=~latitude, lng=~longitude,
group = groups[8],
popup= ~popup ,
fillColor = ~pal(obs_category),
fillOpacity = 0.8,
radius = ~4,
stroke=FALSE) %>%
leaflet::addCircleMarkers(data= lakes_ewr_pgdl_light,
lat=~latitude, lng=~longitude,
group = groups[9],
popup= ~popup ,
fillColor = ~pal(obs_category),
fillOpacity = 0.8,
radius = ~4,
stroke=FALSE) %>%
leaflet::addCircleMarkers(data= lakes_ewr_nokw_pgdl_gucci,
lat=~latitude, lng=~longitude,
group = groups[10],
popup= ~popup ,
fillColor = ~pal(obs_category),
fillOpacity = 0.8,
radius = ~4,
stroke=FALSE) %>%
leaflet::addCircleMarkers(data= lakes_ewr_nokw_pgdl_light,
lat=~latitude, lng=~longitude,
group = groups[11],
popup= ~popup ,
fillColor = ~pal(obs_category),
fillOpacity = 0.8,
radius = ~4,
stroke=FALSE) %>%
leaflet::addLegend(data = lake_summary_df, pal = pal,
position = 'bottomleft',
values=~obs_category,
labFormat = leaflet::labelFormat(digits = 0),
title = "Number of temp observations") %>%
addLayersControl(
baseGroups = groups,
options = layersControlOptions(collapsed = FALSE)
) %>%
hideGroup(groups[-1])
```