rsMove (version 0.2.8)

timeDir: timeDir

Description

Analysis of environmental change in time for a set of coordinate pairs.

Usage

timeDir(
  env.data,
  env.dates,
  obs.dates,
  temporal.buffer,
  xy = NULL,
  stat.fun = NULL,
  min.count = 2
)

Arguments

env.data

Object of class RasterStack or RasterBrick or data.frame.

env.dates

Object of class Date with env.data observation dates.

obs.dates

Object of class Date with xy observation dates.

temporal.buffer

two element vector with temporal window size (expressed in days).

xy

Object of class "SpatialPoints" or "SpatialPointsDataFrame".

stat.fun

Output statistical metric.

min.count

Minimum number of samples required by stat.fun. Default is 2.

Value

A vector with a requested statistical metric for each point in xy and informative plots.

Details

This function quantifies environmental change in time along a movement track. First, for each point in xy, the function compares its observation date (obs.dates) against the acquisition dates (env.dates) of env.data to select non NA timesteps within a predefined temporal window (temporal.buffer). The user can adjust this window to determine which images are the most important. For example, if one wishes to know how the landscape evolved up to the observation date of the target sample, temporal.buffer can be define as, e.g., c(30,0) forcing the function to only consider pixels recorded within the previous 30 days. After selecting adequate temporal information for each data point, a statistical metric is estimated. This statistical metric is specified by stat.fun. By default, the function reports on the slope between the acquisition dates of env.data and their corresponding values. When providing a new function, set x for env.dates and y for env.data. The final output is a list consisting of:

  • stats - data.frame with the estimated statistical metric for each data point.

  • hist.plot - Histogram plot of the requested statistical metric. The bin size is the standard deviation of all estimated values.

  • point.plot - Plot of the xy showing the spatial variability of the requested statistical metric.

See Also

spaceDir dataQuery imgInt

Examples

Run this code
# NOT RUN {
{

 require(raster)

 # read raster data
 file <- list.files(system.file('extdata', '', package="rsMove"), 'ndvi.tif', full.names=TRUE)
 r.stk <- stack(file)
 r.stk <- stack(r.stk, r.stk, r.stk) # dummy files for the example

 # read movement data
 data(shortMove)

 # raster dates
 r.dates <- seq.Date(as.Date("2013-08-01"), as.Date("2013-08-09"), 1)

 # sample dates
 obs.dates <- as.Date(shortMove@data$date)

 # perform directional sampling
 of <- function(x,y) {lm(y~x)$coefficients[2]}
 time.env <- timeDir(r.stk, r.dates, obs.dates, c(30,30), xy=shortMove, stat.fun=of)

}
# }

Run the code above in your browser using DataLab