rtsa.stl: Raster time series STL (Seasonal Trend Decomposition using...

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/rtsa.stl.R

Description

This function conducts a Seasonal Trend Decomposition using Loess (STL) from raster time series using "stlplus" package especially designed to handle gappy time series.

Usage

1
2
3
4
rtsa.stl(rasterts, rastermask = NULL, gapfill = "none", cores = 1L,
  n.p = NULL, s.window = "periodic", t.window = NULL, s.degree = 1L,
  t.degree = 1L, only.statistics = FALSE, keep.original = FALSE,
  verbose = FALSE)

Arguments

rasterts

Input raster time series as RasterStackTS or RasterBrickTS object.

rastermask

Either a RasterLayer or "compute". Raster layer to use as a mask. When "compute" is set raster mask is computed to remove all pixels with incomplete time series.

gapfill

Character. Defines the algorithm to be used to interpolate pixels with incomplete temporal profiles. Accepts argument supported as method in function rtsa.gapfill.

cores

Integer. Defines the number of CPU to be used for multicore processing. Default to "1" core for singlecore processing.

n.p

Integer. Argument to be passed to function stlplus. Periodicity of the seasonal component. Default to the frequency estimated from of the time series.

s.window

Argument to be passed to function stlplus. Either the character string "periodic" (default) or the span (in lags) of the loess window for seasonal extraction, which should be odd.

t.window

Integer. Argument to be passed to function stlplus. The span (in lags) of the the loess window for trend extraction, which should be odd. Default to the entire time series duration.

s.degree

Integer. Argument to be passed to function stlplus. Degree of locally-fitted polynomial in trend extraction. Should be 0, 1 (default) or 2.

t.degree

Integer. Argument to be passed to function stlplus. Degree of locally-fitted polynomial in trend extraction. Should be 0, 1 (default) or 2.

only.statistics

Logical. If TRUE returns only the statistics from seasonal, trend and remainder components.

keep.original

Logical. If TRUE returns the original raster time series values in the 'rts' slot of STDstack-class object.

...

Additional arguments to be passed through to function stlplus.

Value

Object of class STDstack-class containing the following components:

std Seasonal Trend Decomposition method used
mask Final raster mask of computed pixels as RasterLayer object
seasonal_amplitude Amplitude of seasonal component (statistic) as RasterLayer object
seasonal_amplitude_stdev Standard deviation computed from the amplitude of seasonal component (statistic) as RasterLayer object (only returned when running function rtsa.seas)
trend_slope Trend slope computed from trend component (yearly statistic) as RasterLayer object
residual_stdev Standard deviation computed from the remainder component (statistics) as RasterLayer object
rts Input raster time series as RasterBrickTS object (only returned if keep.original = TRUE)
seasonality Seasonal component as RasterBrickTS object
trend Trend component as RasterBrickTS object
seasonaladjtrend Seasonal adjusted trend component as RasterBrickTS object (only returned when running function rtsa.seas)
remainder Remainder component as RasterBrickTS object

Author(s)

Federico Filipponi

References

Cleveland, R.B., Cleveland, W.S., Terpenning, I. (1990). STL: A seasonal-trend decomposition procedure based on loess. Journal of Official Statistics, 6(1), 3.

Hafen, R.P. (2010). Local regression models: Advancements, applications, and new methods. West Lafayette, Indiana: Purdue University, PhD dissertation, pp. 279.

See Also

stlplus, rtsa.seas, rtsa.gapfill, seas, stl, decompose

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
## create raster time series using the 'pacificSST' data from 'remote' package
require(remote)

data(pacificSST)
pacificSST[which(getValues(pacificSST == 0))] <- NA # set NA values
# create rts object
rasterts <- rts(pacificSST, seq(as.Date('1982-01-15'), as.Date('2010-12-15'), 'months'))

## generate raster mask
raster_mask <- pacificSST[[1]] # create raster mask
names(raster_mask) <- "mask"
values(raster_mask) <- 1 # set raster mask values
raster_mask[which(is.na(getValues(pacificSST[[1]])))] <- 0 # set raster mask values

## compute Seasonal Trend Decomposition analysis
# compute 'STL'
std_result <- rtsa.stl(rasterts=rasterts, rastermask=raster_mask)
# compute STL' with multiple cores support and returning the original raster values
std_result <- rtsa.stl(rasterts=rasterts, rastermask=raster_mask, cores=2, keep.original=TRUE)
# compute STL' using additional arguments to define loess window
std_result <- rtsa.stl(rasterts=rasterts, rastermask=raster_mask, n.p=12, t.window=48)

## End(Not run)

ffilipponi/rtsa documentation built on Oct. 18, 2019, 12:37 a.m.