-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.Rmd
522 lines (408 loc) · 18.9 KB
/
index.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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
---
output:
html_document:
self_contained: false
css: styles.css
---
```{r setup, message = F, warning = F, results = 'hide', echo = FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = F, message = F, echo = F, fig.path = 'figs/', fig.path = 'figures/')
library(tidyverse)
library(lubridate)
library(plotly)
library(colorspace)
library(reactable)
library(downloadthis)
library(tools)
library(shiny)
library(crosstalk) # use v1.1.1 to remove (All) from table filter selection
library(DT)
library(scales)
library(plotrix)
library(here)
library(showtext)
data(tnanndat)
data(mosdat)
data(mosentdat)
data(totanndat)
data(npsmosdat)
data(npsdpsips)
data(npsdpsipsent)
data(npsmosludat)
data(mohydat)
source(here('R/funcs.R'))
source(here('R/figs.R'))
levs <- c('All Segments (- N. BCB)', 'Old Tampa Bay', 'Hillsborough Bay', 'Middle Tampa Bay', 'Lower Tampa Bay', 'Remainder Lower Tampa Bay')
# # style file
# styles <- readLines('https://raw.githubusercontent.com/tbep-tech/css-styling/master/styles.css')
# writeLines(styles, 'styles.css')
```
# {.tabset .tabset-fade .tabset-pills}
## Summary
Total nitrogen load estimates to Tampa Bay for the 1970s and 2020 by source:
```{r}
column(12,
column(3,
download_file(
path = here('figs/3dload_pies.png'),
output_name = "TN-summary",
output_extension = ".xlsx",
button_label = "Download plot",
button_type = "info",
has_icon = TRUE,
icon = "fa fa-save"
)
)
)
```
<br><br>
```{r, out.width = '80%'}
knitr::include_graphics('figs/3dload_pies.png')
```
<br>
Nitrogen inputs into Tampa Bay are a key limiting nutrient that can stimulate algal growth and negatively affect seagrass habitat. The long-term recovery of Tampa Bay is attributed to the successful nitrogen reduction efforts of the Tampa Bay [Nitrogen Management Consortium](https://tbep.org/our-work/boards-committees/nitrogen-management-consortium/){target="_parent"}. Nitrogen loads and sources are routinely estimated for Tampa Bay and reported to the Florida Department of Environmental Protection and US Environmental Protection Agency under a 5-year [Reasonable Assurance Plan](https://drive.google.com/file/d/10IjJAfcGFf007a5VdPXAUtUi4dx-cmsA/view){target="_parent"}.
This dashboard provides a summary of nitrogen load estimates in various formats (all estimates from Janicki Environmental, Inc.). Load estimates are partitioned into one of five categories by source:
* __AD__: atmospheric deposition
* __DPS__: domestic point source
* __GWS__: groundwater source
* __IPS__: industrial point source
* __NPS__: nonpoint source
Source estimates for total nitrogen are shown annually from 1985 to present, by month from 2017 to 2021 (previous Reasonable Assurance period, also including total phosphorus, total suspended solids, and BOD), and by month from 2004 to 2021 for select sources (DPS reuse, DPS end of pipe, IPS, NPS). The totals tab shows annual results for total nitrogen (TN), hydrologic load, and total nitrogen vs hydrologic load ratios. The load ratio plots show adopted numeric nutrient criteria for TN as horizontal lines that are applicable to each bay segment.
Estimates are also assigned to individual bay segments recognized in the Tampa Bay [Reasonable Assurance Plan](https://drive.google.com/file/d/10IjJAfcGFf007a5VdPXAUtUi4dx-cmsA/view){target="_parent"}: Old Tampa Bay, Hillsborough Bay, Middle Tampa Bay, Lower Tampa Bay, and the Remainder of Lower Tampa Bay. The "Remainder of Lower Tampa Bay" includes the Manatee River, Terra Ceia Bay, and southern Boca Ciega Bay. Estimates for all segments are also provided as the sum of loads across the four major bay segments and the remainder of Lower Tampa Bay. Note that this does not include the northern portion of Boca Ciega Bay (i.e., __(- N. BCB)__ in the tables and plots).
Annual load targets for total nitrogen (US tons/yr) by major bay segments are as follows ([2009 RA Addendum](https://drive.google.com/file/d/10IjJAfcGFf007a5VdPXAUtUi4dx-cmsA/view){target="_parent"}, shown on relevant annual load plots):
* Old Tampa Bay: 486 tons (US) / year
* Hillsborough Bay: 1451 tons (US) / year
* Middle Tampa Bay: 799 tons (US) / year
* Lower Tampa Bay: 349 tons (US) / year
* Remainder of Lower Tampa Bay: 629 tons (US) / year
Hydrologically-normalized load targets, as a ratio of total nitrogen to hydrologic load (nitrogen delivery ratios) for each bay segment, are also shown on relevant plots ([2009 RA Addendum](https://drive.google.com/file/d/10IjJAfcGFf007a5VdPXAUtUi4dx-cmsA/view){target="_parent"}). These nitrogen delivery ratios have been adopted as the annual RA compliance assessment thresholds and/or [estuarine numeric nutrient criteria](https://www.flrules.org/gateway/RuleNo.asp?title=SURFACE%20WATER%20QUALITY%20STANDARDS&ID=62-302.532){target="_parent"} for Tampa Bay and are as follows :
* Old Tampa Bay: 1.08 tons/million cubic meters of water
* Hillsborough Bay: 1.62 tons/million cubic meters of water
* Middle Tampa Bay: 1.24 tons/million cubic meters of water
* Lower Tampa Bay: 0.97 tons/million cubic meters of water
* Remainder of Lower Tampa Bay: 1.59 tons/million cubic meters of water
+ Boca Ciega Bay South: 0.97 tons/million cubic meters of water
+ Terra Ceia Bay: 1.10 tons/million cubic meters of water
+ Manatee River Estuary: 1.80 tons/million cubic meters of water
* Boca Ciega Bay North: 1.54 tons/million cubic meters of water
<img src="figs/segmap.png" alt="Major bay segments in Tampa Bay used to assign load estimates. The Remainder of Lower Tampa Bay includes the Manatee River, Terra Ceia Bay, and Boca Ciega Bay. Figure courtesy of Janicki Environmental, Inc." width="40%" />
## Total nitrogen (annual, 1985 - 2021) {.tabset}
```{r}
column(12,
column(3,
tnanndat %>%
download_this(
output_name = "TN-annual",
output_extension = ".xlsx",
button_label = "Download plot data",
button_type = "info",
has_icon = TRUE,
icon = "fa fa-save"
)
)
)
```
<br></br>
<br></br>
### By source
Dotted line is annual bay segment target.
```{r, out.width = '100%', out.height='1000px'}
tnsrc_plo(tnanndat, xval = 'year', src = 'all', addtnlns = T)
```
### Table
```{r}
rct_tab(tnanndat, dtvar = 'year', typ = 'tn')
```
### Metadata
Data from the __Download plot data__ button includes the following:
* __*year*__: year of the estimate
* __*bay_segment*__: the bay segment for the source/year estimate, one of Old Tampa Bay, Hillsborough Bay, Middle Tampa Bay, Lower Tampa Bay, Remainder of Lower Tampa Bay (Manatee River, Terra Ceia Bay, and Boca Ciega Bay South), and all segments as the sum of all (excluding Boca Ciega Bay North)
* __*source*__: total nitrogen source as atmospheric deposition (AD), domestic point source (DPS), groundwater source (GWS), industrial point source (IPS), and non-point source (NPS)
* __*tn_load*__: total nitrogen load in tons (US) / year
## Total nitrogen, phosphorus, suspended solids, and BOD by source (monthly, 1995 - 2021) {.tabset}
```{r}
column(12,
column(3,
mosdat %>%
download_this(
output_name = "monthly",
output_extension = ".xlsx",
button_label = "Download all plot data",
button_type = "info",
has_icon = TRUE,
icon = "fa fa-save"
)
),
column(3,
mosentdat %>%
download_this(
output_name = "entity-monthly",
output_extension = ".xlsx",
button_label = "Download all entity data",
button_type = "info",
has_icon = TRUE,
icon = "fa fa-save"
)
)
)
```
<br></br>
<br></br>
### Total nitrogen by source
```{r, out.width = '100%', out.height='1000px'}
tnsrc_plo(mosdat, xval = 'date', src = 'all', yval = 'tn_load')
```
### Total nitrogen table
```{r}
rct_tab(mosdat, dtvar = 'date', typ = 'tn', val = 'tn_load')
```
### Total phosphorus by source
```{r, out.width = '100%', out.height='1000px'}
tnsrc_plo(mosdat, xval = 'date', src = 'all', yval = 'tp_load')
```
### Total phosphorus table
```{r}
rct_tab(mosdat, dtvar = 'date', typ = 'tn', val = 'tp_load')
```
### Total suspended solids by source
```{r, out.width = '100%', out.height='1000px'}
tnsrc_plo(mosdat, xval = 'date', src = 'all', yval = 'tss_load')
```
### Total suspended solids table
```{r}
rct_tab(mosdat, dtvar = 'date', typ = 'tn', val = 'tss_load')
```
### BOD by source
```{r, out.width = '100%', out.height='1000px'}
tnsrc_plo(mosdat, xval = 'date', src = 'all', yval = 'bod_load')
```
### BOD table
```{r}
rct_tab(mosdat, dtvar = 'date', typ = 'tn', val = 'bod_load')
```
### Metadata
Data from the __Download all plot data__ button includes monthly estimates by bay segment and source for total nitrogen, phosphorus, suspended solids, and BOD. Columns are as follows:
* __*year*__: year of the estimate (1995 - 2021)
* __*month*__: month of the estimate
* __*bay_segment*__: the bay segment for the source/year estimate, one of Old Tampa Bay, Hillsborough Bay, Middle Tampa Bay, Lower Tampa Bay, Remainder of Lower Tampa Bay (Manatee River, Terra Ceia Bay, and Boca Ciega Bay South), and all segments as the sum of all (excluding Boca Ciega Bay North)
* __*source*__: total nitrogen source as atmospheric deposition (AD), domestic point source (DPS), groundwater source (GWS), industrial point source (IPS), and non-point source (NPS)
* __*tn_load*__: total nitrogen load in tons / month
* __*tp_load*__: total phosphorus load in tons / month
* __*tss_load*__: total suspended solids load in tons / month
* __*bod_load*__: biological oxygen demand in tons / month
Data from the __Download all entity data__ button includes the following:
* __*year*__: year of the estimate (2017 - 2021)
* __*month*__: month of the estimate
* __*bayseg*__: bay segment where the load applies
* __*entity*__: entity responsible for the load, e.g., a specific wastewater treatment plant
* __*source*__: total nitrogen source as atmospheric deposition (AD), domestic point source (DPS), groundwater source (GWS), industrial point source (IPS), and non-point source (NPS)
* __*tn_load*__: total nitrogen load in tons / month
## Total hydrologic load (monthly, 1985 - 2021) {.tabset}
```{r}
column(12,
column(3,
mohydat %>%
download_this(
output_name = "monthly-hydrology",
output_extension = ".xlsx",
button_label = "Download all plot data",
button_type = "info",
has_icon = TRUE,
icon = "fa fa-save"
)
)
)
```
<br></br>
<br></br>
### Plot
```{r, out.width = '100%', out.height='1000px'}
hy_plo(mohydat)
```
### Table
```{r}
hy_tab(mohydat)
```
### Metadata
Data from the __Download all plot data__ button includes the following:
* __*year*__: year of the estimate
* __*month*__: month of the estimate
* __*bay_segment*__: the bay segment for the month estimate, one of Old Tampa Bay, Hillsborough Bay, Middle Tampa Bay, Lower Tampa Bay, Remainder of Lower Tampa Bay (Manatee River, Terra Ceia Bay, and Boca Ciega Bay South), and all segments as the sum of all (excluding Boca Ciega Bay North)
* __*hy_load_106_m3_mo*__: hydrologic load as 10$^6$ m$^3$/month
## Non-point source by land use (monthly, 2004 - 2021) {.tabset}
```{r}
column(12,
# column(3,
# npsdpsips %>%
# download_this(
# output_name = "TN-select-sources-monthly",
# output_extension = ".xlsx",
# button_label = "Download plot data",
# button_type = "info",
# has_icon = TRUE,
# icon = "fa fa-save"
# )
# ),
# column(3,
# npsdpsipsent %>%
# download_this(
# output_name = "TN-entity-monthly",
# output_extension = ".xlsx",
# button_label = "Download entity data",
# button_type = "info",
# has_icon = TRUE,
# icon = "fa fa-save"
# )
# ),
column(3,
npsmosludat %>%
download_this(
output_name = "TN-lu-monthly",
output_extension = ".xlsx",
button_label = "Download NPS by land use",
button_type = "info",
has_icon = TRUE,
icon = "fa fa-save"
)
)
)
```
<br></br>
<br></br>
<!-- ### By source -->
<!-- ```{r, out.width = '100%', out.height='1000px'} -->
<!-- tnsrc_plo(npsdpsips, xval = 'date', src = 'select') -->
<!-- ``` -->
<!-- ### Table -->
<!-- ```{r} -->
<!-- rct_tab(npsdpsips, dtvar = 'date', typ = 'tn') -->
<!-- ``` -->
### Non-point source by land use
```{r, out.width = '100%', out.height = '250px'}
dat <- npsmosdat %>%
group_by(year, bay_segment, month, lu) %>%
summarise(tn_load = sum(tn_load, na.rm = T), .groups = 'drop') %>%
mutate(dy = 1) %>%
unite('date', year, month, dy, sep = '-') %>%
mutate(
date = ymd(date),
tn_load = round(tn_load, 1)
) %>%
spread(bay_segment, tn_load, fill = 0) %>%
select(date, lu, `Old Tampa Bay`, `Hillsborough Bay`, `Middle Tampa Bay`, `Lower Tampa Bay`, `Remainder Lower Tampa Bay`)
toplo <- highlight_key(dat)
filter_select("filter", "Select land use", toplo, ~lu, multiple = F)
showleg <- F
cols <- qualitative_hcl(5, palette = "Dynamic")
plot_ly(toplo, alpha = 1, fill = 'tonexty') %>%
add_markers(x = ~date, y = ~`Remainder Lower Tampa Bay`, color = I(cols[1]), stackgroup = 'one', mode = 'none', marker = list(opacity = 0, size = 0), showlegend = T, legendgroup = 'grp1', name = 'Remainder Lower Tampa Bay') %>%
add_markers(x = ~date, y = ~`Lower Tampa Bay`, color = I(cols[2]), stackgroup = 'one', mode = 'none', marker = list(opacity = 0, size = 0), showlegend = T, legendgroup = 'grp2', name = 'Lower Tampa Bay') %>%
add_markers(x = ~date, y = ~`Middle Tampa Bay`, color = I(cols[3]), stackgroup = 'one', mode = 'none', marker = list(opacity = 0, size = 0), showlegend = T, legendgroup = 'grp3', name = 'Middle Tampa Bay') %>%
add_markers(x = ~date, y = ~`Hillsborough Bay`, color = I(cols[4]), stackgroup = 'one', mode = 'none', marker = list(opacity = 0, size = 0), showlegend = T, legendgroup = 'grp4', name = 'Hillsborough Bay') %>%
add_markers(x = ~date, y = ~`Old Tampa Bay`, color = I(cols[5]), stackgroup = 'one', mode = 'none', marker = list(opacity = 0, size = 0), showlegend = T, legendgroup = 'grp5', name = 'Old Tampa Bay') %>%
layout(
xaxis = list(title = NA, gridcolor = '#FFFFFF'),
yaxis = list(title = 'TN load (tons / mo)', gridcolor = '#FFFFFF'),
barmode = 'stack',
legend = list(title = list(text = 'Bay segment'), traceorder = 'reversed')
) %>%
config(
toImageButtonOptions = list(
format = "svg",
filename = "myplot"
)
)
datatable(toplo, extensions="Scroller", style="bootstrap", class="compact", width="100%",
options=list(deferRender=TRUE, scrollY=300, scroller=TRUE,
columnDefs = list(list(visible = F, targets = 2)),
headerCallback = DT::JS(
"function(thead) {",
" $(thead).css('font-size', '0.8em');",
"}"
)),
colnames = c('Date', 'Land use', 'Old Tampa Bay', 'Hillsborough Bay', 'Middle Tampa Bay', 'Lower Tampa Bay', 'Remainder Lower Tampa Bay')) %>%
formatStyle(columns = 1:7, fontSize = '80%')
```
```{js}
function filter_default() {
document.getElementById("filter").getElementsByClassName("selectized")[0].selectize.setValue("High Density Residential", false);
}
window.onload = filter_default;
```
### Metadata
<!-- Data from the __Download plot data__ button includes the following: -->
<!-- * __*year*__: year of the estimate -->
<!-- * __*month*__: month of the estimate -->
<!-- * __*bay_segment*__: the bay segment for the source/year estimate, one of Old Tampa Bay, Hillsborough Bay, Middle Tampa Bay, Lower Tampa Bay, Remainder of Lower Tampa Bay (Manatee River, Terra Ceia Bay, and Boca Ciega Bay South), and all segments as the sum of all (excluding Boca Ciega Bay North) -->
<!-- * __*source*__: total nitrogen source as domestic point source reuse (DPS - reuse), domestic point source end of pipe (DPS - end of pipe), industrial point source (IPS), and non-point source (NPS) -->
<!-- * __*tn_load*__: total nitrogen load in tons / month -->
<!-- Data from the __Download entity data__ button includes the following: -->
<!-- * __*year*__: year of the estimate -->
<!-- * __*month*__: month of the estimate -->
<!-- * __*bayseg*__: bay segment where the load applies -->
<!-- * __*entity*__: entity responsible for the load, e.g., a specific wastewater treatment plant -->
<!-- * __*source*__: total nitrogen source as atmospheric deposition (AD), domestic point source (DPS), groundwater source (GWS), industrial point source (IPS), and non-point source (NPS) -->
<!-- * __*tn_load*__: total nitrogen load in tons / month -->
Data from the __Download NPS by land use__ button includes the following:
* __*year*__: year of the estimate
* __*month*__: month of the estimate
* __*bay_segment*__: the bay segment for the source/year estimate, one of Old Tampa Bay, Hillsborough Bay, Middle Tampa Bay, Lower Tampa Bay, Remainder of Lower Tampa Bay (Manatee River, Terra Ceia Bay, and Boca Ciega Bay South), and all segments as the sum of all (excluding Boca Ciega Bay North)
* __*land use*__: land use type associated with the load
* __*source*__: total nitrogen source as non-point source (NPS)
* __*tn_load*__: total nitrogen load in tons / month
## Totals {.tabset}
```{r}
column(12,
column(3,
totanndat %>%
download_this(
output_name = "hydro-annual",
output_extension = ".xlsx",
button_label = "Download plot data",
button_type = "info",
has_icon = TRUE,
icon = "fa fa-save"
)
)
)
```
<br></br>
<br></br>
### Total Nitrogen
Dotted line is annual bay segment target.
```{r, out.width = '100%', out.height='1000px'}
ldtot_plo(totanndat, yval = 'tn_load')
```
### Total Phosphorus
Dotted line is annual bay segment target.
```{r, out.width = '100%', out.height='1000px'}
ldtot_plo(totanndat, yval = 'tp_load')
```
### Hydrology
Dotted line is annual bay segment target.
```{r, out.width = '100%', out.height='1000px'}
ldtot_plo(totanndat, yval = 'hy_load')
```
### Total Nitrogen vs Hydrology
Dotted line is annual bay segment target.
```{r, out.width = '100%', out.height='1000px'}
ldtot_plo(totanndat, yval = 'tnhy')
```
### Total Phosphorus vs Hydrology
Dotted line is annual bay segment target.
```{r, out.width = '100%', out.height='1000px'}
ldtot_plo(totanndat, yval = 'tphy')
```
### Table
```{r}
rct_tab(totanndat, dtvar = 'year', typ = 'tots')
```
### Metadata
Data from the __Download plot data__ button includes the following:
* __*year*__: year of the estimate
* __*bay_segment*__: the bay segment for the source/year estimate, one of Old Tampa Bay, Hillsborough Bay, Middle Tampa Bay, Lower Tampa Bay, Remainder of Lower Tampa Bay (Manatee River, Terra Ceia Bay, and Boca Ciega Bay South), and all segments as the sum of all (excluding Boca Ciega Bay North)
* __*tn_load*__: total nitrogen load in tons (US) / year
* __*tp_load*__: total phosphorus load in tons (US) / year
* __*hy_load*__: hydrologic load in million cubic meters / year
* __*tnhy*__: ratio between total nitrogen and hydrologic loads
* __*tphy*__: ratio between total phosphorus and hydrologic loads
<script type="text/javascript" src="js/iframeResizer.contentWindow.min.js"></script>