rsMove (version 0.2.1)

timeDir: timeDir

Description

Temporal directional raster analysis.

Usage

timeDir(xy = NULL, ot = ot, img = NULL, edata = NULL, rt = rt,
  mws = NULL, dir = NULL, fun = NULL)

Arguments

xy

Object of class "SpatialPoints" or "SpatialPointsDataFrame".

ot

Object of class Date, POSIXlt or POSIXct with xy observation dates.

img

Object of class RasterStack or RasterBrick.

edata

Object of class data frame.

rt

Object of class Date, POSIXlt or POSIXct with img observation dates.

mws

Moving window size (expressed in days).

dir

One of fwd, bwd or both. Default is both.

fun

Summary function.

Value

A vector.

Details

This function evaluates how do environmental conditions change in time along a movement track. First, it compares the observation times (ot) of xy against the acquisition times (rt) of img to search for relevant information within a pre-defined temporal window (mws). The user can chose to only consider time steps before (bwd) or after (fwd the target observation time or look at both directios (both). If the latest is chosen, the function applies mws equally to both directions. After selecting adequate temporal information, a statistical metric (fun) is used to summarize the selected time steps. By default, the slope will be used. The slope is estimated from a linear regression estimated between the acquisition times of img and their corresponding values. When providing a new function, set x for time and y for the raster values. The output reports on:

  • x - mean x coordinates

  • y - mean y coordinates

  • timestamp - mean observation time

  • pixel.time - elapsed time within a pixel for a given segment

  • stat: statistical metric

If edata is provided, img will be ignores as edata will contain the environmental data with each column representing a different variable. Otherwise, this data will be retrieved from img. Also, if edata is provided, xy is not required. However, it can be provided to built a spatial plot with the results of the analysis.

See Also

spaceDir dataQuery imgInt

Examples

Run this code
# NOT RUN {
{

 require(raster)

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

 # read movement data
 moveData <- read.csv(system.file('extdata', 'konstanz_20130804.csv', package="rsMove"))
 moveData <- SpatialPointsDataFrame(moveData[,1:2], moveData, proj4string=crs(rsStk))

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

 # sample dates
 ot <- strptime(paste0(moveData@data$date, ' ',moveData@data$time), format="%Y/%m/%d %H:%M:%S")

 # perform directional sampling
 of <- function(x,y) {lm(y~x)$coefficients[2]}
 time.env <- timeDir(xy=moveData, ot=ot, img=rsStk, rt=rd, mws=10, dir="bwd", fun=of)

}
# }

Run the code above in your browser using DataLab