Learn R Programming

RGISTools (version 1.0.2)

genFilterStack: Subset a RasterStack given a range of dates

Description

genFilterStack filters the RasterLayers within a range of dates.

Usage

genFilterStack(r, ...)

Arguments

r

the RasterStack to be filtered.

...

arguments for nested functions:

  • startDate a Date class object with the starting date of the study period.

  • endDate a Date class object with the ending date of the study period.

  • AppRoot the path where the RData will be saved.

Value

a RasterStack with images within the specified dates.

Details

This is a helper function used by other functions in this package.

Examples

Run this code
# NOT RUN {
# generate random images
img <- matrix(1:16, ncol = 4, byrow = TRUE)
r <- raster(img)
r <- stack(r, r, r, r, r, r)
names(r) <- paste0("RandomImage_201803", 1:6)
# print the names and dates of the random images
print(names(r))
genGetDates(names(r))
# example of filtering the raster stack
r2 <- genFilterStack(r = r,
                     startDate = as.Date("2018-02-02", "%Y-%m-%d"),
                     endDate = as.Date("2018-02-04", "%Y-%m-%d"))
# print the names and the number of layers of the filtered stack
genGetDates(names(r2))
nlayers(r2)
# }

Run the code above in your browser using DataLab