knitr::opts_chunk$set( collapse = TRUE, comment = "#>", warning = F ) # devtools::install_local(force = T) # devtools::load_all()
library(seascapeR)
ERDDAP dataset info and date ranges for two available datasets: global_monthly and global_8day.
# SeaScape dataset info ss_gl_mo <- get_ss_info() # default: dataset = "global_monthly" ss_gl_8d <- get_ss_info("global_8day") ss_gl_mo ss_gl_8d # SeaScape date ranges get_ss_dates(ss_gl_mo) get_ss_dates(ss_gl_8d)
# show dataset of Seascape Global Classes information ss_gl_classes # setup paths for plots generated in tables below dir_svg <- here::here("inst/svg") web_svg <- "../svg" # show table for Seascape Class 1 tbl_ss_class(1, dir_svg, web_svg) # show table for Seascape Class 15 tbl_ss_class(15, dir_svg, web_svg) # show table for Seascape Class 33 tbl_ss_class(33, dir_svg, web_svg)
Get interactive map of Seascape classes:
map_ss_wms(ss_gl_mo)
Note that the image tiles produces by the Web Map Server (WMS) do not contain the data, just tiled image.
You can use any sf
polygon object. This package has a couple helper functions to get polygons of interest, either a National Marine Sanctuary or a simple bounding box.
# bounding box for Florida Keys area lon = -81.3; lat = 24.5; w = 1.2 ply <- bbox_ply(lon - w, lat - w, lon + w, lat + w) map_ss_wms(ss_gl_mo, ply)
# setting variables and paths allows for caching data files sanctuary = "fknms" # or see: ?get_url_ply dir_data = here::here("data_ss") dir_ply = glue::glue("{dir_data}/ply") dir_ply # get sanctuary polygon ply <- get_url_ply( sanctuary = sanctuary, dir_ply = dir_ply)
# show files fs::dir_tree(dir_ply)
# map image tiles with polygon map_ss_wms(ss_gl_mo, ply)
# variables and paths ss_dataset = "global_8day" # or "global_8day" ss_var = "CLASS" # or "P" date_beg = "2022-10-16" date_end = "2023-02-10" dir_grd = glue::glue( "{dir_data}/{sanctuary}_{ss_dataset}") ss_info <- get_ss_info(dataset = ss_dataset) # get SeaScape grids from polyon for date range grds <- get_ss_grds( ss_info, ply, ss_var = ss_var, date_beg = date_beg, date_end = date_end, dir_tif = dir_grd, verbose = T) # show files fs::dir_tree(dir_grd)
# get first grid, a raster layer in the raster stack grds grd <- raster::raster(grds, 1) # map SeaScape grid map_ss_grd(grd)
ts_csv = glue::glue( "{dir_data}/{sanctuary}_{ss_dataset}_{ss_var}.csv") tbl <- sum_ss_grds_to_ts(grds, ts_csv = ts_csv) tbl
# plot SeaScape time series plot_ss_ts(tbl)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.