Learn R Programming

rsMove (version 0.2.4)

spaceDir: spaceDir

Description

Analysis of environmental change in space along a set of coordinate pairs.

Usage

spaceDir(xy, img, sample.direction, data.type, obs.time = NULL,
  distance.method = "m", buffer.size = NULL, stat.fun = NULL,
  min.count = 2)

Arguments

xy

Object of class SpatialPoints or SpatialPointsDataFrame.

img

Object of class RasterLayer.

sample.direction

One of forward, backward or both. Default is both.

data.type

One of 'cont' or 'cat'. Defines which type of variable is in use.

obs.time

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

distance.method

One of 'm' or 'deg' specifying the projection unit. Default is 'm'.

buffer.size

Spatial buffer size expressed in the map units.

stat.fun

Output statistical metric.

min.count

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

Value

A list containing shapefiles with information on environmental change and travel distance/time and a plot of the results.

Details

This function evaluates how do environmental conditions change in space along a movement track. For each set of consecutive points, the function applies a spatial moving window which boundaries depend on the definition of sample.direction. Then, within each segment, the function extracts all pixels within it. If buffer.size is defined, the function will consider a buffer when performing this extraction. Finally, the the extracted NA values are summarized into a given metric. If data.type is cont, a statistical function can be provided through stat.fun. However, if data.type is cat, the function will report on the dominant class and on the shannon index for each segment. Note that the function will work with the raster value associated to each class. On top of this, spaceDir will also report on the linear distance traveled between endpoints (in meters) and the travel time (in minutes). The output of the function is a list consisting of:

  • endpoints - Point shapefile with endpoints of each spatial segment. Reports on a given statistical metric, traveled distance, travel time and the mean timestamp.

  • segments - Line shapefile with spatial segments. Reports on the same information as endpoints. plot - Plotting of segments where each segment is colored according to its corresponding statistical value.

See Also

timeDir dataQuery imgInt

Examples

Run this code
# NOT RUN {
{

 require(raster)

 # read raster data
 r <- raster(system.file('extdata', '2013-07-16_ndvi.tif', package="rsMove"))

 # read movement data
 data(shortMove)

 # observation time
 obs.time <- strptime(paste0(shortMove@data$date, ' ',shortMove@data$time),
 format="%Y/%m/%d %H:%M:%S")

 # perform directional sampling
 of <- function(x) {lm(x~c(1:length(x)))$coefficients[2]}
 s.sample <- spaceDir(shortMove, r, "backward", "cont", obs.time=obs.time, stat.fun=of)

}
# }

Run the code above in your browser using DataLab