Given a polygon and date range, fetch Seascape data and return a raster layer for a single date or raster stack if multiple dates found for given date range.

get_ss_grds(
  ss_info,
  ply,
  ss_var = "CLASS",
  date_beg = min(get_ss_dates(ss_info)),
  date_end = max(get_ss_dates(ss_info)),
  dir_tif = NULL,
  del_cache = F,
  verbose = F
)

Arguments

ss_info

SeaScape ERDDAP info object, as returned by get_ss_info)

ply

polygon as spatial feature sf, as returned by get_url_ply or bbox_to_ply

ss_var

SeaScape variable. One of "CLASS" (default) or "P" for probability.

date_beg

date begin to fetch, as character ("2003-01-15") or Date (Date("2003-01-15")). Defaults to first date available from ss_info.

date_end

date end to fetch, as character ("2020-11-15") or Date (Date("2020-11-15")). Defaults to latest date available from ss_info.

dir_tif

directory to cache results. Files are stored in the format grd_{ss_var}_{date}.tif so any other information needed, such as place or SeaScape dataset should be captured by the containing folders so as to not inadvertently write or read the wrong grid. This folder is consulted for available dates before fetching any missing from the ERDDAP server.

del_cache

Delete ERDDAP cache with cache_delete_all, which may be necessary if underlying data changed. Default: FALSE.

verbose

display messages on status of function. Useful for debugging or showing status while getting data from a wide range and/or big polygon. Default: FALSE.

Value

Raster raster layer if one date, stack if more

Examples

ply <- get_url_ply("mbnms") ss_i <- get_ss_info() grds <- get_ss_grds(ss_i, ply, date_beg = "2020-01-01") grds
#> class : RasterBrick #> dimensions : 48, 41, 1968, 13 (nrow, ncol, ncell, nlayers) #> resolution : 0.05, 0.05 (x, y) #> extent : -123.15, -121.1, 35.5, 37.9 (xmin, xmax, ymin, ymax) #> crs : +proj=longlat +datum=WGS84 +no_defs #> source : memory #> names : CLASS_2020.01.15, CLASS_2020.02.15, CLASS_2020.03.15, CLASS_2020.04.15, CLASS_2020.05.15, CLASS_2020.06.15, CLASS_2020.07.15, CLASS_2020.08.15, CLASS_2020.09.15, CLASS_2020.10.15, CLASS_2020.11.15, CLASS_2020.12.15, CLASS_2021.01.15 #> min values : 7, 14, 7, 12, 7, 12, 7, 7, 12, 14, 14, 14, 14 #> max values : 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21 #>