Summarize Seascape grids into a table having columns: date, cellvalue (ie CLASS), number of cells (n_cells) and percent of cells (pct_cells).

sum_ss_grds_to_ts(grds, ts_csv = NULL, verbose = F)

Arguments

grds

raster stack with more than one date, as returned by get_ss_grds

ts_csv

path to csv to save this time series table. Default is NULL, in which case the table is not saved. If path is set and already exists then that will be read in if all dates in the grds are present instead of recalculating and writing to ts_csv. Another file with attributes (per Details) is also saved using the same path with the extra *_attr.csv suffix.

verbose

show messages of process. Useful for debugging. Default: FALSE.

Value

tibble of data

Details

This function is particularly helpful in between using get_ss_grds() and plot_ss_ts().

Note that the minimum number of class NA cells across all dates get subtracted from each of the NA class across all dates. These NAs are mostly attributable to the polygon mask within the polygon's bounding box, as given by ply argument to get_ss_grds(), since the resulting grids are square and get assigned NA values outside the polygon within the polygon's bounding box. Some of the NA values may also be attributable to the land mask or consistent cloud cover across all dates. Attributes get assigned to the output table object:

Examples

ply <- get_url_ply("mbnms") ss_i <- get_ss_info() grds <- get_ss_grds(ss_i, ply, date_beg = "2020-01-01") tbl <- sum_ss_grds_to_ts(grds) tbl
#> # A tibble: 61 x 4 #> date cellvalue n_cells pct_cells #> <date> <int> <int> <dbl> #> 1 2020-01-15 7 2 0.00336 #> 2 2020-01-15 12 31 0.0520 #> 3 2020-01-15 14 558 0.936 #> 4 2020-01-15 21 2 0.00336 #> 5 2020-01-15 NA 3 0.00503 #> 6 2020-02-15 14 543 0.911 #> 7 2020-02-15 19 12 0.0201 #> 8 2020-02-15 21 39 0.0654 #> 9 2020-02-15 NA 2 0.00336 #> 10 2020-03-15 7 3 0.00503 #> # … with 51 more rows
# extra attributes assigned; see Details attr(tbl, "n_cells")
#> [1] 1968
attr(tbl, "n_cells_na")
#> [1] 1372
attr(tbl, "pct_cells_na")
#> [1] 0.6971545