Learn R Programming

rsMove (version 0.1)

timeDirSample: timeDirSample

Description

Temporal forward and backward sampling of a raster time series using GPS tracking data.

Usage

timeDirSample(xy = xy, ot = ot, img = img, 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.

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 SpatialPointsDataFrame.

Details

This function evaluates how do environmental conditions change in time along a movement track. Before an output is returned, the function looks for segments of consecutive samples that appear within the same pixel and provides mean values for their coordinates and observation times as well as the corresponding pixel value and the elapsed time during the segment (in minutes). this step avoids the replication of samples while preserving observation related to revisits to the same pixels. Then, the function 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

See Also

spaceDirSample dataQuery

Examples

Run this code
# NOT RUN {
{
 
 require(raster)
 
 # read movement data
 file <- system.file('extdata', 'konstanz_20130804.shp', package="rsMove")
 moveData <- shapefile(file)
 
 # 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
 
 # raster dates
 rd = seq.Date(as.Date("2013-08-01"), as.Date("2013-08-09"), 1)
 
 # sample dates
 td = as.Date(moveData@data$date)
 
 # perform directional sampling
 of <- function(x,y) {lm(y~x)$coefficients[2]}
 t.sample <- timeDirSample(xy=moveData, ot=td, img=rsStk, rt=rd, mws=10, dir="bwd", fun=of)
 
}
# }

Run the code above in your browser using DataLab