This function extracts along a spatial gradient (e.g. along latitude) time series from a raster brick and computes for each position a temporal trend.
1 2 3 4 5  TrendGradient(r, start = c(1982, 1), freq = 12, gradient.r = NULL,
gradient.brks = NULL, funSpatial = "mean", cor.area = FALSE,
scalar = 1, method = c("AAT", "STM", "SeasonalAdjusted"),
mosum.pval = 0.05, h = 0.15, breaks = 0, funAnnual = mean,
funSeasonalCycle = MeanSeasonalCycle, percent = FALSE)

r 
multilayer raster object of class 
start 
beginning of the time series (i.e. the time of the first observation). The default is c(1982, 1), i.e. January 1982 which is the usual start date to compute trends on longterm series of satellite observations of NDVI. See 
freq 
The frequency of observations. The default is 12 for monthly observations. Use 24 for bimonthly observations, 365 for daily observations or 1 for annual observations. See 
gradient.r 
raster layer with the variable that has a spatial gradient. If NULL (default) a gradient along latitude will be used. Alternatively, one could provide here for example a raster layer with a gradient along longitude for longitudinal gradients of trends or a raster layer with mean annual temperatures to compute trends along a temperature gradient. 
gradient.brks 
breaks for the gradient. These breaks define the class intervals for which time series will be extracted and trends computed. If NULL (default) 15 class breaks between the minimum and maximum values of the gradient will be used. 
funSpatial 
function that should be used for spatial aggregation of grid cells that belong to the same interval. 
cor.area 
If TRUE grid cell values are multiplied by grid cell area to correct for area. 
scalar 
Multiplier to be applied to time series (e.g. for unit conversions). 
method 
method to be used for trend calculation with the following options:

mosum.pval 
Maximum pvalue for the OLSMOSUM test in order to search for breakpoints. If p = 0.05, breakpoints will be only searched in the time series trend component if the OLSMOSUM test indicates a significant structural change in the time series. If p = 1 breakpoints will be always searched regardless if there is a significant structural change in the time series or not. See 
h 
minimal segment size either given as fraction relative to the sample size or as an integer giving the minimal number of observations in each segment. See 
breaks 
maximal number of breaks to be calculated (integer number). By default the maximal number allowed by h is used. See 
funAnnual 
function to aggregate time series to annual values if 
funSeasonalCycle 
a function to estimate the seasonal cycle of the time series if

percent 
return trend as percentage change 
The function returns a list of class 'TrendGradient'
The function returns a data.frame of class 'TrendGradient'.
Matthias Forkel <matthias.forkel@geo.tuwien.ac.at> [aut, cre]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  # load a multitemporal raster dataset of Normalized Difference Vegetation Index
data(ndvimap)
plot(ndvimap, 8)
# compute a latitudinal gradient of trends (by default the method 'AAT' is used):
gradient < TrendGradient(ndvimap, start=c(1982, 1), freq=12)
gradient
plot(gradient)
# shown is the trend at each latitudinal band, the area represents the 95%
# confidence interval of the trend (computed with function TrendUncertainty),
# symbols indicate the pvalue of the trend at each latitude
plot(gradient, type="yx") # the gradient can be also plotted in reversed order
# latitudinal gradient with different number of intervals:
gradient < TrendGradient(ndvimap, start=c(1982, 1), freq=12,
gradient.brks=seq(66, 69, length=5))
plot(gradient)
# example for a longitudinal gradient:
gradient.r < raster(ndvimap, 1) # create a raster layer with longitudes:
gradient.r[] < xFromCell(gradient.r, 1:ncell(gradient.r))
plot(gradient.r)
gradient < TrendGradient(ndvimap, start=c(1982, 1), freq=12,
gradient.r=gradient.r)
plot(gradient, xlab="Longitude (E)")

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.