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_ed_grds(
  ed_info,
  ply,
  ed_var = "CLASS",
  date_beg = min(get_ed_dates(ed_info)),
  date_end = max(get_ed_dates(ed_info)),
  dir_tif = NULL,
  del_cache = F,
  verbose = T
)

Arguments

ed_info

SeaScape ERDDAP info object, as returned by ed_info)

ply

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

ed_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 ed_info.

date_end

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

dir_tif

directory to cache results. Files are stored in the format grd_{ed_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")
#> Error in dir_create(dir_ply): could not find function "dir_create"
ed_i <- ed_info()
#> Error in ed_info(): argument "dataset" is missing, with no default
grds <- get_ed_grds(ed_i, ply, date_beg = "2020-01-01")
#> Error in get_ed_dates(ed_info): could not find function "get_ed_dates"
grds
#> Error in eval(expr, envir, enclos): object 'grds' not found