-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFK_DB_Test1.qmd
114 lines (103 loc) · 3.66 KB
/
FK_DB_Test1.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
---
title: "Florida Keys Data Dash"
author: "USF IMaRS"
date: "2/3/2023"
format: html
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
# whatever is in this chunk gets run before any other chunk
# install.packages("rerddap")
# install.packages("plotdap")
# install.packages("mapdata")
# install.packages("leaflet")
# install.packages("stringr")
# install.packages("dplyr")
# install.packages("readr")
# install.packages("here")
# install.packages("flexdashboard")
# put your libary loading here:
library("rerddap")
library("mapdata")
library("plotdap")
library("leaflet")
library("stringr")
library("dplyr")
library("leafem")
library("readr")
library("here")
library("flexdashboard")
```
```{r}
# source(here::here("scripts/functions.R"))
dashboard <- "FKNMS"
# Set Bounds from "ROI_INFO.csv" (can add other columns)
site <- read_csv("data/ROI_INFO.csv", col_types=cols()) %>% # Pull ROI bounds from file.
filter(grepl(dashboard, ROI))
# slat <- site$slat; nlat <- site$nlat ; wlon <- site$wlon; elon <- site$elon
# For some reason, bounds don't set exactly right. Some sort of buffer? Depends on view/render?
# Set manually for now
# Could pull ERDDAP data from all of GoM instead and just zoom to ROI.
slat <- 24; nlat <- 26 ; wlon <- -83; elon <- -79.5
date_tmp <- '2017-01-01'
# L3 Ocean Color from IMaRS (ERDDAP)
sst4 <- info('moda_sst4_7d_fk' , url = "http://131.247.136.200:8080/erddap/")
chl <- info('moda_oc_7d_fk' , url = "http://131.247.136.200:8080/erddap/")
# Seascapes from AOML Coastwatch (ERDDAP)
# scape <- info("noaa_aoml_4729_9ee6_ab54", url = "https://cwcgom.aoml.noaa.gov/erddap/")
get_dates <- function(info){
info$alldata$time %>%
filter(attribute_name=="actual_range") %>%
pull(value) %>%
str_split(", ", simplify = T) %>%
as.numeric() %>%
as.POSIXct(origin = "1970-01-01", tz = "GMT")
}
# get most recent date
d <- get_dates(chl)[2]
```
::: {.panel-tabset}
## Chlorophyll-a
```{r}
# Leaflet map
leaflet(options = leafletOptions(crs = leafletCRS(crsClass = "L.CRS.EPSG4326"))) %>%
# basemap from GBIF in 4326
addTiles("//tile.gbif.org/4326/omt/{z}/{x}/{y}@1x.png?style=gbif-geyser") %>%
# Call to IMaRS ERDDAP (chlor_a)
addWMSTiles(
baseUrl = 'http://131.247.136.200:8080/erddap/wms/moda_oc_7d_fk/request?',
layers = "moda_oc_7d_fk:chlor_a_median",
options = WMSTileOptions(
version = "1.3.0", format = "image/png", transparent = T, opacity = 0.7,
time = "2023-01-07T00:00:00Z")) %>%
# Add Markers if needed
# addMarkers(lng = ~lon, lat = ~lat, label = ~name, data=site) %>%
addMouseCoordinates() %>%
fitBounds(wlon, slat, elon, nlat) %>% # Can render past bounds depending on browser window
addLegend(
position="bottomright",
title = paste0("CHLa (mg m^-3)<br>", date_tmp),
colorNumeric("Spectral", c(0,30), reverse=T), seq(0,30))
```
## SST
```{r}
# Leaflet map
leaflet(options = leafletOptions(crs = leafletCRS(crsClass = "L.CRS.EPSG4326"))) %>%
# basemap from GBIF in 4326
addTiles("//tile.gbif.org/4326/omt/{z}/{x}/{y}@1x.png?style=gbif-geyser") %>%
# Call to IMaRS ERDDAP (chlor_a)
addWMSTiles(
baseUrl = 'http://131.247.136.200:8080/erddap/wms/moda_sst4_7d_fk/request?',
layers = "moda_sst4_7d_fk:sst4_median",
options = WMSTileOptions(
version = "1.3.0", format = "image/png", transparent = T, opacity = 0.7,
time = "2022-09-02T00:00:00Z")) %>%
# addMarkers(lng = ~lon, lat = ~lat, label = ~name, data=site) %>%
addMouseCoordinates() %>%
fitBounds(wlon, slat, elon, nlat) %>%
addLegend(
position="bottomright",
title = paste0("SST (DegC)<br>", date_tmp),
colorNumeric("Spectral", c(0,30), reverse=T), seq(0,30))
```
:::