Learn R Programming

bfastSpatial (version 0.6.2)

annualSummary: Annual summary of a time series RasterBrick

Description

Calculates pixel-based statistics for every year represented by a time series RasterBrick

Usage

annualSummary(x, fun, dates = NULL, years = NULL, sensor = NULL,
  na.rm = NULL, ...)

Arguments

x

RasterBrick or RasterStack

fun

Function to apply over each pixel for each year

dates

Date. Optional: vector of dates exactly corresponding to the layers of x. If not included, dates must be included in the z dimension of x (see getZ) or in names(x)

years

Numeric. Optional: Vector of years to which to limit the summary.

sensor

Character. Optional: limit calculation to images from a particular sensor. Defaults to "all", but can take any of "TM", "ETM+", "ETM+ SLC-off" or "ETM+ SLC-on". Will be ignored with a warning if names(x) do not correspond to Landsat scene ID's.

...

Arguments to be passed to mc.calc

Value

RasterBrick with results of fun for each year represented in the input time series RasterBrick.

Details

If fun takes a na.rm argument and none is supplied, the default value for na.rm for that function will be used.

See Also

summaryBrick

Examples

Run this code
# NOT RUN {
# load tura RasterBrick
data(tura)

# calculate mean and standard deviation values per year for ETM+ data only
annualMean <- annualSummary(tura, fun=mean, na.rm=TRUE, sensor="ETM+")
plot(annualMean)
annualSD <- annualSummary(tura, fun=sd, na.rm=TRUE, sensor="ETM+")
plot(annualSD)

# custom function to calculate # of non-NA values per pixel per year (similar to countObs())
ff <- function(x)
 length(x[!is.na(x)])
annualObs <- annualSummary(tura, fun=ff, sensor="ETM+")
# }

Run the code above in your browser using DataLab