temporalMetrics: Calculate temporal summary metrics

Description Usage Arguments Details See Also Examples

View source: R/temporalMetrics.R

Description

This function calculates a set of user-defined or default statistics from spectral indices time series.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
temporalMetrics(
  x,
  metrics = "defaultTemporalSummary",
  filename = "",
  stack = TRUE,
  par = FALSE,
  threads = 2,
  progress = TRUE,
  m = 2,
  ...
)

Arguments

x

List of Raster* or SpatialPointsDataFrame objects.Input Raster or SpatialPointsDataFrame object containing a time series (may be generated with calcIndices)

metrics

Name of a function used to process the time series provided as a character.

filename

Character. Single output filename including path to directory and eventually extension. Each spectral index is written separately and the name of the spectral index is automatically appended to the file name.

stack

Logical. Should the output be returned as a single RasterStack (TRUE) or as a list containing one Raster per vegetation index (FALSE)

par

Logical. Should the function be executed in parallel threads

threads

Number of parallel threads used if par = TRUE

progress

Logical. If TRUE (default) a progress bar is displayed.

m

tuning parameter to determine how many blocks will be used (m blocks will be processed by each cluster)

...

Other arguments passed to writeRaster or writeOGR.

Details

Spectral indices can be calculated with calcIndices. The input to TemporalMetrics is a list where each element is a Raster* or a SpatialPointsDataFrame object with layers or columns being spectral indices. Each element should be one step in the time series and elements should be ordered in the time series ascending order. The argument fun defines which metrics will be calculated. It has to be the name of a function that takes a vector as input and returns a named vector corresponding to the summary metrics. The function defaultTemporalSummary is used by default and returns the median, IQR and Theil-Sen slope of the time series.

If x is a list of Raster* objects, the processing can be parallelized using cluster. In that case the user has to set par = TRUE and provide the number of parallel threads threads. You can control how many blocks will be processed by each thread by setting m (see cluster).

See Also

calc, cluster

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# VI_ts is a list of Raster* calculated and saved from calcIndices
# Load it into memory
load(system.file("extdata/examples/VI_ts.RData",package="foster"))

temporalMetrics(VI_ts, metrics = "defaultTemporalSummary")

# User-defined temporal summary metrics can also be used
funSummary <- function(x) {
  c(
    mean = mean(x, na.rm = TRUE),
    median = median(x, na.rm = TRUE),
    std = sd(x, na.rm = TRUE)
  )
}

mqueinnec/foster documentation built on March 28, 2021, 4:27 p.m.