subset_datacube: subset_datacube

Description Usage Arguments Details Value Examples

View source: R/subset_datacube.R

Description

This function subsets a datacube (RasterStack or RasterBrick) based on dates.

Usage

1
subset_datacube(r, from, to)

Arguments

r

is the Raster layer to compare to the climatology.

from

string, starting date (e.g. "2018-12-30").

to

string, ending date (e.g. "2018-12-31").

Details

If the from and to strings are in the format "YYYY-MM-DD", they are automatically converted into a date.

Value

The function returns a subset of r, with layer's date in the range starting with from and ending with to.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
  r <- raster(nrows = 2, ncols = 2,
              xmn = 0, xmx = 360, ymn = -90, ymx = 90, vals = 30)
  # Generate dummy RasterBrick
  b <- raster::brick(lapply(1:(365 * 3),
                     function(i) raster::setValues(r,
                     unif(n = raster::ncell(r), min = 0, max = 100))))
  names(b) <- seq.Date(from = as.Date("1993-01-01"),
                       to = as.Date("1995-12-31"),
                       by = "day")
  subset_datacube(r = b, from = "1993-01-01", to = "1993-01-01")

## End(Not run)

caliver documentation built on Feb. 19, 2021, 5:07 p.m.