Learn R Programming

rsMove (version 0.1)

spaceDirSample: spaceDirSample

Description

Spatial forward and backward sampling of a raster using GPS tracking data.

Usage

spaceDirSample(xy = xy, ot = ot, img = img, dir = dir, 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 RasterLayer.

dir

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

fun

Summary function.

Value

A list.

Details

This function evaluates how do environmental conditions change in space 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, for each observation, the function looks at it imediate neighbors to define spatial segments over which a statistical metric will be estimated. All the pixels between the two endpoints of the segment are considered in this process. By defaut, the slope of the linear regression between the first and the last observation is returned. The user can use the argument dir # to prompt the function to focus at previous (bwd) or following (fwd) observations or to look in both directions (both). The output consists of a list containing two shapefiles, one SpatialPointsDataFrame ($endpoints) with the endpoints of each segment and a SpatialLinesDataFrame ($segments) representing each segment. The data frames provided with these shapefiles 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

  • travel.distance - distance between a segment endpoints

  • travel.time - elapsed time between a segment endpoints

  • stat: statistical metric

See Also

timeDirSample dataQuery

Examples

Run this code
# NOT RUN {
{
 
 require(rgdal)
 require(raster)
 require(sp)
 
 # read movement data
 file <- system.file('extdata', 'konstanz_20130804.shp', package="rsMove")
 moveData <- shapefile(file)
 
 # observation time
 td <- as.Date(moveData@data$date)
 
 # read raster data
 r <- raster(system.file('extdata', 'tcb_1.tif', package="rsMove"))
 
 # perform directional sampling
 of <- function(x,y) {lm(y~x)$coefficients[2]}
 s.sample <- spaceDirSample(xy=moveData, ot=td, img=r, dir="bwd", fun=of)
 
}
# }

Run the code above in your browser using DataLab