-
Notifications
You must be signed in to change notification settings - Fork 3
/
wq-dash.Rmd
943 lines (690 loc) · 34.6 KB
/
wq-dash.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
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
---
title: "TAMPA BAY WATER QUALITY DASHBOARD"
output:
flexdashboard::flex_dashboard:
logo: www/tarponlogo.png
social: menu
source_code: "https://github.com/tbep-tech/wq-dash"
includes:
in_header: google-analytics.html
runtime: shiny
css: styles.css
---
```{r setup, include=F}
source(here::here('R/global.R'))
```
```{r reactives}
# OTB boxplot
boxplototb <- reactive({
# inputs
yrsselseas <- input$yrsselseas
yrselseas <- input$yrselseas
out <- boxplotly(epcdata, 'OTB', yrselseas, yrsselseas, pthm)
return(out)
})
# OTB boxplot click
otbclkrct <- reactive({
selin <- plotly::event_data("plotly_click", source = 'otbclk', priority = 'event')
boxplototb <- boxplototb()
validate(
need(!is.null(selin), 'Click point from plot to view algae counts')
)
out <- try({selfun(selin, boxplototb, algdat, epcdata, 'OTB')}, silent = TRUE)
validate(
need(nrow(out) > 0, 'No phytoplankton data')
)
return(out)
})
# OTB algae selection
otbalg <- reactive({
otbclkrct <- otbclkrct()
out <- algselplo(otbclkrct, algnms, cols)
return(out)
})
# HB boxplot
boxplothb <- reactive({
# inputs
yrsselseas <- input$yrsselseas
yrselseas <- input$yrselseas
out <- boxplotly(epcdata, 'HB', yrselseas, yrsselseas, pthm)
return(out)
})
# HB boxplot click
hbclkrct <- reactive({
selin <- plotly::event_data("plotly_click", source = 'hbclk')
boxplothb <- boxplothb()
validate(
need(!is.null(selin), 'Click point from plot to view algae counts')
)
out <- selfun(selin, boxplothb, algdat, epcdata, 'HB')
validate(
need(nrow(out) > 0, 'No phytoplankton data')
)
return(out)
})
# HB algae selection
hbalg <- reactive({
hbclkrct <- hbclkrct()
out <- algselplo(hbclkrct, algnms, cols)
return(out)
})
# MTB boxplot
boxplotmtb <- reactive({
# inputs
yrsselseas <- input$yrsselseas
yrselseas <- input$yrselseas
out <- boxplotly(epcdata, 'MTB', yrselseas, yrsselseas, pthm)
return(out)
})
# MTB boxplot click
mtbclkrct <- reactive({
selin <- plotly::event_data("plotly_click", source = 'mtbclk')
boxplotmtb <- boxplotmtb()
validate(
need(!is.null(selin), 'Click point from plot to view algae counts')
)
out <- selfun(selin, boxplotmtb, algdat, epcdata, 'MTB')
validate(
need(nrow(out) > 0, 'No phytoplankton data')
)
return(out)
})
# MTB algae selection
mtbalg <- reactive({
mtbclkrct <- mtbclkrct()
out <- algselplo(mtbclkrct, algnms, cols)
return(out)
})
# LTB boxplot
boxplotltb <- reactive({
# inputs
yrsselseas <- input$yrsselseas
yrselseas <- input$yrselseas
out <- boxplotly(epcdata, 'LTB', yrselseas, yrsselseas, pthm)
return(out)
})
# LTB boxplot click
ltbclkrct <- reactive({
selin <- plotly::event_data("plotly_click", source = 'ltbclk')
boxplotltb <- boxplotltb()
validate(
need(!is.null(selin), 'Click point from plot to view algae counts')
)
out <- selfun(selin, boxplotltb, algdat, epcdata, 'LTB')
validate(
need(nrow(out) > 0, 'No phytoplankton data')
)
return(out)
})
# LTB algae selection
ltbalg <- reactive({
ltbclkrct <- ltbclkrct()
out <- algselplo(ltbclkrct, algnms, cols)
return(out)
})
# map data
maprct <- reactive({
# input
mapref <- input$mapref
if(mapref == 'threshold')
out <- mapdat %>%
dplyr::mutate(
met = ifelse(val < thresh, 'yes', 'no')
)
if(mapref == 'target')
out <- mapdat %>%
dplyr::mutate(
met = ifelse(val < target, 'yes', 'no')
)
return(out)
})
# domain for map color points
mapdmn <- reactive({
# input
maprct <- maprct()
out <- maprct %>%
dplyr::group_by(thr, met) %>%
tidyr::nest() %>%
dplyr::mutate(
rng = purrr::map(data, function(x) range(x$val, na.rm = T))
) %>%
dplyr::select(-data) %>%
tidyr::unnest(rng) %>%
dplyr::ungroup()
return(out)
})
# color palette for target met
palyes <- reactive({
# inputs
thrsel <- input$thrsel
mapdmn <- mapdmn()
dmn <- mapdmn %>%
dplyr::filter(thr == thrsel) %>%
dplyr::filter(met == 'yes') %>%
dplyr::pull(rng)
leaflet::colorNumeric(
palette = RColorBrewer::brewer.pal(4, 'Greens'),
na.color = 'yellow',
domain = dmn
)
})
# color palette for target not met
palno <- reactive({
# inputs
thrsel <- input$thrsel
mapdmn <- mapdmn()
dmn <- mapdmn %>%
dplyr::filter(thr == thrsel) %>%
dplyr::filter(met == 'no') %>%
dplyr::pull(rng)
leaflet::colorNumeric(
palette = RColorBrewer::brewer.pal(4, 'Reds'),
na.color = 'yellow',
domain = dmn
)
})
# site attainment map
attmap <- reactive({
# inputs
thrsel <- input$thrsel
yrsel <- input$yrsel
mapref <- input$mapref
palyes <- palyes()
palno <- palno()
maprct <- maprct()
mapdmn <- mapdmn()
attmaploc <- isolate(attmaploc())
# filter by year to map
toplo <- maprct %>%
dplyr::filter(thr %in% thrsel) %>%
dplyr::select(-thr) %>%
dplyr::filter(yr %in% yrsel) %>%
dplyr::mutate(
cols = dplyr::case_when(
met == 'yes' ~ palyes(val),
met == 'no' ~ palno(val)
),
ptlab = dplyr::case_when(
mapref == 'threshold' ~ thresh,
mapref == 'target' ~ target
)
) %>%
dplyr::left_join(locs, ., by = 'epchc_station')
# polygon attainment data for selected year
attyr <- avedat %>%
dplyr::filter(yr %in% yrsel) %>%
dplyr::left_join(tbseg, ., by = 'bay_segment') %>%
dplyr::mutate(
outcome = dplyr::case_when(
outcome == 'lightgreen' ~ '#2DC938',
outcome == 'yellow' ~ '#E9C318',
outcome == 'red' ~ '#CC3231'
)
)
# values to feed to legend
yesval <- mapdmn %>% dplyr::filter(thr == thrsel) %>% dplyr::filter(met == 'yes') %>% dplyr::pull(rng)
noval <- mapdmn %>% dplyr::filter(thr == thrsel) %>% dplyr::filter(met == 'no') %>% dplyr::pull(rng)
# for point scaling, original range
scls <- dplyr::case_when(
thrsel == 'chla' ~ c(0.59, 58),
thrsel == 'la' ~ c(0.38, 5.92)
)
# map with custom legends
out <- tbeptools::util_map(toplo) %>%
leaflet::addPolygons(
data = attyr,
stroke = T,
color = 'grey',
weight = 1,
layerId = ~long_name,
fillColor = ~outcome,
fillOpacit = 0.5,
label = ~paste0(bay_segment, ': ', long_name, ', Action: ', action, ' (', outcome, ')')
) %>%
leaflet::addCircleMarkers(
data = toplo,
layerId = ~epchc_station,
stroke = TRUE,
color = 'black',
fill = TRUE,
fillColor = ~cols,
weight = 1,
fillOpacity = 1,
radius=~scales::rescale(val, from = scls, to = c(5, 20)),
label = ~paste0('Station ', epchc_station, ' (', mapref, ' met: ', met, ', value ', round(val, 2), ', ', mapref, ' ', ptlab, ')')
) %>%
leaflet::addLegend("topright", labels = c("Stay the Course", "Caution", "On Alert"), colors = c("#2DC938", "#E9C318", "#CC3231"), title = "Bay segment decision<br>matrix outcomes", opacity = 1) %>%
leaflet::addLegend("bottomright", pal = palno, title = paste0("Station ", mapref, "<br>not met"), labels = thrsel, opacity = 1, values = noval) %>%
leaflet::addLegend("bottomright", pal = palyes, title = paste0("Station ", mapref, "<br>met"), labels = thrsel, opacity = 1, values = yesval)
if(length(attmaploc) != 0)
out <- out %>%
leaflet::setView(lng = attmaploc$lng, lat = attmaploc$lat, zoom = attmaploc$zoom)
return(out)
})
# attmap locations
attmaploc <- reactive({
if(is.null(input$attmap_center))
return(list())
list(
zoom = input$attmap_zoom,
lat = input$attmap_center$lat,
lng = input$attmap_center$lng
)
})
# selected site plots
selplo <- reactive({
selsit <- input$map_marker_click$id
selsit_plo(selsit)
})
```
```{r map}
bsmap <- tbeptools::util_map(locs) %>%
leaflet::addCircleMarkers(
data = locs,
layerId = ~epchc_station,
color = '#00806E',
stroke = F,
fillOpacity = 0.9,
radius = 15,
label = ~epchc_station,
labelOptions = leaflet::labelOptions(
textOnly = T,
noHide = T,
style = list(
"color" = "#FFFFFF"
),
direction = 'center'
)
) %>%
leaflet::addCircleMarkers(
data = locs[1, ],
layerId = 'selsit',
stroke = T,
color = '#5C4A42',
fill = F,
radius = 16,
opacity = 1
)
# leaflet proxy for marker select
map <- leaflet::leafletProxy('map')
observeEvent(input$map_marker_click, {
selsit <- input$map_marker_click$id
# get station selection
selsitplo <- locs %>%
dplyr::filter(epchc_station %in% selsit)
# clear markers on input select, add all points and selected point
map <- map %>%
leaflet::removeMarker('selsit') %>%
leaflet::addCircleMarkers(
data = selsitplo,
layerId = 'selsit',
stroke = T,
color = '#5C4A42',
fill = F,
radius = 16,
opacity = 1
)
})
```
```{r downloadhandlers}
# wq data
output$wqdwntab <- downloadHandler(
filename = function(){'wqdat.csv'},
content = function(file){
# inputs
seldl <- input$seldl
todl <- epcdata %>%
dplyr::filter(epchc_station %in% as.numeric(seldl)) %>%
dplyr::select(bay_segment, epchc_station, SampleTime, yr, mo, Latitude, Longitude, secchi_m = sd_raw_m, secchi_q = sd_q, chla, chla_q)
write.csv(todl, file, quote = T, row.names = F)
}
)
# algae data
output$algdwntab <- downloadHandler(
filename = function(){'algdat.csv'},
content = function(file){
# inputs
seldl <- input$seldl
todl <- algdat %>%
dplyr::filter(epchc_station %in% as.numeric(seldl))
write.csv(todl, file, quote = T, row.names = F)
}
)
```
OVERVIEW
===========================================================
Column {.tabset .tabset-fade data-width=650}
-----------------------------------------------------------------------
### USING THE DASHBOARD
<div class = "row">
<div class = "col-md-2"></div>
<div class = "col-md-8">
#### WELCOME TO THE TAMPA BAY WATER QUALITY REPORT CARD!
```{r out.width='100%', fig.align='center'}
knitr::include_graphics('www/bannerimage.jpg')
```
This dashboard synthesizes over forty years of water quality data from Tampa Bay, Florida. The data have been collected monthly, with the only exception being March and April 2020. Information from this dashboard informs the management of environmental resources for the region under direction of the Tampa Bay Estuary Program. The different pages under the __PAGE SELECTION__ menu can be used to view the long-term trends in water quality for each bay segment and individual monitoring stations.
1) [__ATTAINMENT MATRICES__](#attainment-matrices): This page shows the overall report card for the bay as management action categories described in the methods tab. Separate matrices for chlorophyll and light attenuation exceedances for major bay segments are also shown. An interactive map is provided that shows attainment outcomes by year for individual stations in the bay.
1) [__SEGMENT ANNUAL TRENDS__](#segment-annual-trends): This page shows time series of annual chlorophyll and light attenuation averages for each bay segment. Blue lines on each plot show management targets or thresholds that define exceedance categories used to create the management action categories. In between the chlorophyll and light attenuation plots is the attainment matrix outcomes that are specific to each segment.
1) [__SEGMENT SEASONAL TRENDS__](#segment-seasonal-trends): This page shows the seasonal distributions by bay segment for chlorophyll and light attenuation. Each boxplot shows the monthly distribution of observations across all available years in the dataset. The jittered points overlaid on the boxplots show the individual values for a specific year and the large red point shows the current year. Each observation can be clicked to view the observed phytoplankton cell counts for the selected year/month.bay segment combination.
1) [__SITE TRENDS__](#site-trends): This page shows the time series for chlorophyll and light attenuation at individual stations (as compared to segment averages in the other pages). Stations can be selected by clicking on the location in the map. Phytoplankton cell counts can also be viewed as quarterly sums (every three months) across the period of record.
The plots in this dashboard are interactive and display options can be controlled using a mouse. Most plots include a [control menu](https://help.plot.ly/zoom-pan-hover-controls/) on the top with different options for viewing the data. For example, click the camera icon to download a png file for a plot.
<br>
```{r, fig.align='center', out.width='30%'}
knitr::include_graphics('www/plotcontrols.PNG')
```
<br>
#### Website information
Questions and comments about the dashboard can be sent to [Marcus Beck](mailto:[email protected]). The website source content can be viewed on [Github](https://github.com/tbep-tech/wq-dash). All data were obtained from the Environmental Protection Commission of Hillsborough County (accessible [here](http://www.epchc.org/i-want-to/view-gis-maps-and-data)). Like this app? Share it on social media using the [\#TampaBayOpenSci](https://twitter.com/hashtag/TampaBayOpenSci?src=hashtag_click) hashtag.
Citation info here: [![DOI](https://zenodo.org/badge/223773148.svg)](https://zenodo.org/badge/latestdoi/223773148)
<a rel='license' href='http://creativecommons.org/licenses/by/4.0/'><img alt='Creative Commons License' style='border-width:0' src='https://i.creativecommons.org/l/by/4.0/88x31.png' /></a> This website is licensed under a <a rel='license' href='http://creativecommons.org/licenses/by/4.0/'>Creative Commons Attribution 4.0 International License</a>.
</div>
<div class = "col-md-2"></div>
</div>
### METHODS
<div class = "row">
<div class = "col-md-2"></div>
<div class = "col-md-8">
#### Decision support approach
Light availability to seagrass is the guiding paradigm for the Tampa Bay Estuary Program's ([TBEP](https://www.tbep.org)) Nitrogen Management Strategy. Because excessive nitrogen loads to the bay generally lead to increased algae blooms (higher chlorophyll-a levels) and reduce light penetration to seagrass, an evaluation method was developed to assess whether load reduction strategies are achieving desired water quality results (i.e. reduced chlorophyll-a concentrations and increased water clarity).
```{r out.width='50%', fig.align='center', fig.cap='The guiding paradigm for seagrass restoration through nitrogen management.'}
knitr::include_graphics('www/nitro.jpg')
```
The attainment outcomes shown in the various dashboard pages are built on a rigorous technical foundation. Year to year algae abundance (measured as chlorophyll-a concentrations) and visible light penetration through the water column (secchi disk depth visibility) have been identified as critical water quality indicators in Tampa Bay. Tracking the attainment of bay segment specific targets for these indicators provides the framework for developing and initiating bay management actions. TBEP management actions adopted in response to the annually-assessed decision support results are shown below.
<span style="color:#2DC938">__Stay the Course__</span>: Continue planned projects. Report data via annual progress reports and Baywide Environmental Monitoring Report.
<span style="color:#E9C318">__Caution__</span>: Review monitoring data and nitrogen loading estimates. Begin/continue TAC and Management Board development of specific management recommendations.
<span style="color:#CC3231">__On Alert__</span>: Finalize development and implement appropriate management actions to get back on track.
The management category or action is based on the combination of annual outcomes for chlorophyll and light attenuation. For each year, major bay segments are assigned to outcome categories based on both the exceedance of the annual estimate above a threshold or target and duration of the exceedance for the years prior. Exceedances are defined as either small or large based on the magnitude and short or long based on the duration within the previous four years. The combination of these exceedance categories creates an outcome integer that each bay segment is assigned for both chlorophyll and light attenuation.
```{r out.width='60%', fig.align='center', fig.cap='Outcomes for annual estimates of water quality are assigned an integer value from zero to three depending on both magnitude and duration of the exceedence.'}
knitr::include_graphics('www/outints.png')
```
The chlorophyll and light attenuation outcome integers are then combined to create the management category for each bay segment.
```{r out.width='60%', fig.align='center', fig.cap='Management action categories assigned to each bay segment and year based on chlorophyll and light attenuation outcomes.'}
knitr::include_graphics('www/matrixcats.png')
```
</div>
<div class = "col-md-2"></div>
</div>
### DOWNLOAD DATA
<div class = "row">
<div class = "col-md-2"></div>
<div class = "col-md-8">
Click the buttons below to download water quality and phytoplankton cell count data. Select all data or specific stations. Please note that these data have been modified from the raw data provided by EPC (link below) for the purposes of this application. View the separate pages for an explanation of the data.
```{r}
column(12,
column(4, "Select stations to download:"),
column(4, "Water quality data:"),
column(4, "Phytoplankton data:")
)
column(12,
column(4,
shinyWidgets::pickerInput('seldl', NULL, choices = unique(locs$epchc_station),
selected = unique(locs$epchc_station), multiple = T,
options = list(`actions-box` = TRUE, size = 20), width = '100%')
),
column(4, downloadButtonRmd('wqdwntab', 'Download')),
column(4, downloadButtonRmd('algdwntab', 'Download'))
)
```
</div>
<div class = "col-md-2"></div>
</div>
1 ATTAINMENT MATRICES {data-navmenu="PAGE SELECTION"}
===========================================================
Column {.tabset .tabset-fade data-width=275}
-----------------------------------------------------------------------
### Using this page
This page shows the overall report card for the bay as management action categories:
<span style="color:#2DC938">__Stay the Course__</span>: Continue planned projects. Report data via annual progress reports and Baywide Environmental Monitoring Report.
<span style="color:#E9C318">__Caution__</span>: Review monitoring data and nitrogen loading estimates. Begin/continue TAC and Management Board development of specific management recommendations.
<span style="color:#CC3231">__On Alert__</span>: Finalize development and implement appropriate management actions to get back on track.
Each bay segment (__OTB__: Old Tampa Bay, __HB__: Hillsborough Bay, __MTB__: Middle Tampa Bay, __LTB__: Lower Tampa Bay) is assigned to one of the three above categories for each year of data from 1975 to the current year. The results can be viewed in the *DECISION MATRIX* tab. Hovering the mouse pointer over each cell shows details about the data driving the attainment outcome for a given year:
<br>
```{r, out.width='70%', fig.align='center'}
knitr::include_graphics('www/attainex.PNG')
```
<br>
In the above example, the attainment outcome for Old Tampa Bay in 1980 was <span style="color:#CC3231">On Alert</span>. Additional information on chlorophyll and light attenuation outcomes that drive the overall attainment outcome are also provided. Old Tampa Bay received an outcome of "3" for both chlorophyll and light attenuation results in 1980. Possible integer values range from 0 to 3, with three indicating water quality conditions less suitable for seagrass growth. The integer values describe both a magnitude and duration of exceedance for chlorophyll or light attenuation targets:
<br>
```{r out.width='70%', fig.align='center'}
knitr::include_graphics('www/outints.png')
```
<br>
For each year and bay segment, the final outcome is based on the combination of chlorophyll and light attenuation outcomes:
<br>
```{r out.width='70%', fig.align='center'}
knitr::include_graphics('www/matrixcats.png')
```
<br>
Additional tabs show the chlorophyll and light attenuation exceedance outcomes for each year and bay segment (*CHLOROPHYLL RESULTS*, *LIGHT ATTENUATION RESULTS*). For example, hovering a mouse over the chlorophyll matrix will show the average concentration for the segment and year, whether the value exceeded a "large" magnitude value, and the corresponding value defining the exceedance. In this example, Old Tampa Bay in 1980 had an average chlorophyll concentration of 13.9 ug/L, which was above the threshold of 9.3 for the bay segment.
<br>
```{r, out.width='70%', fig.align='center'}
knitr::include_graphics('www/chlattainex.PNG')
```
<br>
A similar matrix is provided for light attenuation. It is important to note that in both the chlorophyll and light attenuation matrices, the reference values represent a large exceedance value defined as twice the standard error of the historic average for years when water quality conditions were favorable for seagrass growth.
Finally, an interactive map is provided on the right to demonstrate which stations were above or below water quality targets or thresholds defined for each bay segment. The points are color-coded to show if the target or threshold was met and sized by the relative concentration or attenuation values observed in the selected year. Hovering the mouse pointer over each station will show the following:
<br>
```{r, out.width='85%', fig.align='center'}
knitr::include_graphics('www/targetmapex.PNG')
```
<br>
The legends on the bottom-right of the map show the range of values for either chlorophyll (ug/L) or light attenuation (m-1) for stations where targets or thresholds were met or not met. The color ramps can overlap because each segment has different targets or thresholds. Results for different years, for chlorophyll or light attenuation, and references relative to targets or thresholds can be chosen from the drop-down menus.
### DECISION MATRIX
```{r}
attmat
```
### CHLOROPHYLL RESULTS
```{r}
chlmat
```
### LIGHT ATTENUATION RESULTS
```{r}
lamat
```
Column {data-width=500}
-----------------------------------------------------------------------
### SITE ATTAINMENT BY YEAR
```{r ecphc_validate}
output$attmap <- leaflet::renderLeaflet({attmap()})
fillCol(flex = c(NA, 1),
column(12,
column(6,
sliderInput('yrsel', 'Select year:', min = 1975, max = maxyr, value = maxyr, step = 1, sep = '', width = '200%', animate = T),
),
column(3,
selectInput('thrsel', 'Select indicator:', choices = list('Chlorophyll-a (ug /l)' = 'chla', 'Light attenuation (m-1)' = 'la'))
),
column(3,
selectInput('mapref', 'Select map reference:', choices = list('Management target' = 'target', 'Threshold (+2 se)' = 'threshold'))
)
),
leaflet::leafletOutput('attmap')
)
```
2 SEGMENT ANNUAL TRENDS {data-navmenu="PAGE SELECTION"}
===========================================================
Column {data-width=275}
-----------------------------------------------------------------------
### Using this page
This page shows time series of annual chlorophyll and light attenuation averages for each bay segment. Blue lines on each plot show management targets or thresholds that define exceedance categories used to create the management action categories (i.e., <span style="color:#2DC938">__Stay the Course__</span>, <span style="color:#E9C318">__Caution__</span>, or <span style="color:#CC3231">__On Alert__</span>).
In between the chlorophyll (top) and light attenuation (bottom) plots are the attainment matrix outcomes that are specific to each segment. The top row in the matrix shows the attainment outcome for chlorophyll, the bottom row shows the attainment outcome for light attenuation, and the middle row shows the overall management attainment outcome that combines information from both the chlorophyll and light attenuation outcomes. These are the same matrix outcomes as in the __ATTAINMENT MATRICES__ page, but specific to the selected bay segment.
Understanding the results in the plots can provide context for the overall management outcome shown in the middle row of the center plot. The management outcome is based on patterns of both chlorophyll and light attenuation, magnitude of the annual averages, and a temporal component that measures how long exceedances were observed. These outcomes that are assigned to chlorophyll and light attenuation are assigned as follows:
<br>
```{r out.width='80%', fig.align='center'}
knitr::include_graphics('www/outints.png')
```
<br>
For each year, the average chlorophyll and light attenuation values are assigned an integer value from 0 to 3, with higher values indicating less favorable water quality conditions for seagrass growth. Hovering over the center matrix will show the information that was used from the time series plots to determine the management outcome for a given year. For example, Old Tampa Bay in 1980 received a management outcome of <span style="color:#CC3231">__On Alert__</span>:
<br>
```{r out.width='70%', fig.align='center'}
knitr::include_graphics('www/otbout1.PNG')
```
<br>
Both chlorophyll and light attenuation values also received an outcome of "3" for this year. Hovering over the respective cells shows this information:
<br>
```{r out.width='90%', fig.align='center'}
knitr::include_graphics('www/otbout2.PNG')
```
<br>
<br>
```{r out.width='90%', fig.align='center'}
knitr::include_graphics('www/otbout3.PNG')
```
<br>
In both cases, the average values for 1980 for chlorophyll and light attenuation had a large magnitude exceedance of long duration, placing the year in the "3" category. The exceedance values are defined by the blue lines in the time series plots above and below the center matrix. The duration values are defined by how many times the average values were above the management target within the previous four years. A "long" duration means that average values in the previous four years were all above the management target, i.e., the water quality conditions have persisted for some time.
The plots are especially useful to identify which water quality conditions are driving the overall management outcome. Zooming in on 2015 to 2019 for Old Tampa Bay shows that the consistent <span style="color:#E9C318">__Caution__</span> categories are driven by non-sequential years of large magnitude and long duration exceedances for chlorophyll. Light attenuation values have remained below the target.
<br>
```{r out.width='100%', fig.align='center'}
knitr::include_graphics('www/otbout4.PNG')
```
<br>
Column {.tabset .tabset-fade data-width=650}
-----------------------------------------------------------------------
### OLD TAMPA BAY
```{r plot_otb, fig.height = 8, fig.width = 10}
thrplototb
```
### HILLSBOROUGH BAY
```{r plot_hb, fig.height = 8, fig.width = 10}
thrplothb
```
### MIDDLE TAMPA BAY
```{r plot_mtb, fig.height = 8, fig.width = 10}
thrplotmtb
```
### LOWER TAMPA BAY
```{r plot_ltb, fig.height = 8, fig.width = 10}
thrplotltb
```
3 SEGMENT SEASONAL TRENDS {data-navmenu="PAGE SELECTION"}
===========================================================
Column {data-width=275}
-----------------------------------------------------------------------
### Using this page
This page shows the seasonal distributions by bay segment for chlorophyll and light attenuation. The top plot shows chlorophyll distributions by month and the bottom plot shows light attenuation values by month. Each boxplot shows the distribution of observations across all available years for the appropriate month:
<br>
```{r, fig.align='center', out.width='80%'}
knitr::include_graphics('www/boxplotex.png')
```
<br>
Conceptually, boxplots show different values along the distribution range for a collection of observations (e.g., all January chlorophyll observations in Old Tampa Bay across all years). The horizontal line is the median and the box is bounded by the first and third quartiles (i.e., the 25th and 75th percentiles defining the interquartile range) for the data. The whiskers extend beyond the boxes to describe the minimum and maximum values in the data, defined as 1.5 x the interquartile range. Outliers are present above or below the whiskers.
The jittered points overlaid on the boxplots show the individual monthly values for a specific year (i.e., the values that define the dimensions of the boxplot) and the large red point shows the current year. Hovering the mouse pointer over a point shows the year, month, and chlorophyll/light attenuation value for the point. The below example shows the popup text displayed for Old Tampa Bay after hovering over a point in the light attenuation plot on the bottom. The outlier value in July was observed in 1979.
<br>
```{r, fig.align='center', out.width='40%'}
knitr::include_graphics('www/boxplothoverex.PNG')
```
<br>
Each observation can also be clicked to view the observed phytoplankton cell counts for the selected year/month combination. Once a point is clicked, a stacked barplot of count values is shown on the right if phytoplankton data are available for the selected year, month, and bay segment combination. If data are unavailable, text indicating "No phytoplankton data" will be displayed where the plot should be. The count data represent medians across segment stations for different phytoplankton taxa.
Viewing phytoplankton cell count data can be useful to determine if any bloom events may have contributed to conditions that differ from the typical seasonal ranges for a given month. The example below shows counts for July 2019 in Old Tampa Bay. High chlorophyll concentrations were observed in July, which can be explained by blooms of *Pyrodinium bahamense*. The following cell count graph is returned by clicking on the point for July 2019 in the plots for Old Tampa Bay.
<br>
```{r, fig.align='center', out.width='40%'}
knitr::include_graphics('www/otbexphytocount.PNG')
```
<br>
Column {.tabset .tabset-fade data-width=650}
-----------------------------------------------------------------------
<br>
```{r}
mainPanel(
column(6,
sliderInput('yrsselseas', 'Select year range:', min = 1975, max = maxyr, value = c(1975, maxyr), step = 1, sep = '', width = '400%')
),
column(6,
selectInput('yrselseas', 'Select focal year:', selected = maxyr, choices = seq(1975, maxyr))
)
)
```
### OLD TAMPA BAY
```{r boxplot_otb, fig.height = 8, fig.width = 10}
output$boxplototb <- plotly::renderPlotly({
out <- boxplototb()
out$x$source <- 'otbclk'
out
})
output$otbalg <- plotly::renderPlotly(otbalg())
fillRow(flex = c(1, 0.25),
plotly::plotlyOutput('boxplototb'),
plotly::plotlyOutput('otbalg')
)
```
### HILLSBOROUGH BAY
```{r boxplot_hb, fig.height = 8, fig.width = 10}
output$boxplothb <- plotly::renderPlotly({
out <- boxplothb()
out$x$source <- 'hbclk'
out
})
output$hbalg <- plotly::renderPlotly(hbalg())
fillRow(flex = c(1, 0.25),
plotly::plotlyOutput('boxplothb'),
plotly::plotlyOutput('hbalg')
)
```
### MIDDLE TAMPA BAY
```{r boxplot_mtb, fig.height = 8, fig.width = 10}
output$boxplotmtb <- plotly::renderPlotly({
out <- boxplotmtb()
out$x$source <- 'mtbclk'
out
})
output$mtbalg <- plotly::renderPlotly(mtbalg())
fillRow(flex = c(1, 0.25),
plotly::plotlyOutput('boxplotmtb'),
plotly::plotlyOutput('mtbalg')
)
```
### LOWER TAMPA BAY
```{r boxplot_ltb, fig.height = 8, fig.width = 10}
output$boxplotltb <- plotly::renderPlotly({
out <- boxplotltb()
out$x$source <- 'ltbclk'
out
})
output$ltbalg <- plotly::renderPlotly(ltbalg())
fillRow(flex = c(1, 0.25),
plotly::plotlyOutput('boxplotltb'),
plotly::plotlyOutput('ltbalg')
)
```
4 SITE TRENDS {data-navmenu="PAGE SELECTION"}
===========================================================
Column {.tabset .tabset-fade data-width=250}
-----------------------------------------------------------------------
### MAP SELECTION
```{r}
output$map <- leaflet::renderLeaflet(bsmap)
leaflet::leafletOutput('map')
```
### Using this page
This page shows the time series for chlorophyll and light attenuation at individual stations. Data in this page can be useful to determine which stations may be driving segment averages that are displayed on pages 1-3. Similarly, data in this page can be used to understand spatial patterns at scales smaller than individual bay segments. Begin by selecting a station on the map. The selected station will be outlined in brown:
<br>
```{r, fig.align='center', out.width='40%'}
knitr::include_graphics('www/stationsel.PNG')
```
<br>
Plots will appear on the right after a station is selected. The plots show phytoplankton cell counts (top), chlorophyll concentration (middle), and secchi depth (bottom, from which light attenuation is derived). For secchi data, red points indicate when the observation was marked as ">", which usually means the secchi disk was on the bottom and water clarity exceeded the depth at the station at the time of sampling. The three plots are linked and the x-axis can be adjusted to zoom in on a time period of interest. The subplot on the very bottom is a reference for the relative zoom on the x-axis:
<br>
```{r, fig.align='center', out.width='80%'}
knitr::include_graphics('www/stationsel2.PNG')
```
<br>
Ranges on the x-axis can be chosen by clicking on each plot and dragging the mouse pointer over the desired time range. Ranges can also be selected by clicking the buttons on the top that show predefined time periods. For example, selecting the five year button will show data for only five years from the most recent date in the plot. Note the contraction of the reference plot on the very bottom compared to the previous example:
<br>
```{r, fig.align='center', out.width='80%'}
knitr::include_graphics('www/stationsel3.PNG')
```
<br>
The phytoplankton data on the top plot show median cell counts for the selected station in quarterly time steps (e.g., Jan/Feb/Mar 2005, Apr/May/Jun 2005, etc.). These plots are useful to understand variation in dominant phytoplankton taxa over time at a station. The plot can also be filtered to show specific taxa by clicking on the names in the legend. The example below shows trends in *Pyrodinium bahamense* at station 66. Note that the legend entries for all phytoplankton taxa except *Pyrodinium bahamense* are shown in gray, indicating they have been removed from the plot by clicking each one with the mouse.
<br>
```{r, fig.align='center', out.width='100%'}
knitr::include_graphics('www/stationsel4.PNG')
```
<br>
Column {data-width=500}
-----------------------------------------------------------------------
### PLOT
```{r}
output$selplo <- plotly::renderPlotly(selplo())
plotly::plotlyOutput('selplo')
```