spaceDir: spaceDir

View source: R/spaceDir.R

spaceDirR Documentation

spaceDir

Description

Analysis of environmental change in space along a movement track.

Usage

spaceDir(x, y, z, space.buffer, time.buffer, fun, min.count = 2)

Arguments

x

SpatVector object.

y

Object of class SpatRaster.

z

Object of class Date or POSIXct with observation dates for each entry in x.

space.buffer

Spatial buffer size expressed in meters.

time.buffer

Temporal buffer size expressed in days.

fun

List of functions to apply to each time step.

min.count

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

Details

The function quantifies environmental changes along a spatial gradient defined by GPS tracking dataset. For each GPS observation, the function finds the nearest observations within a given buffer.size, and uses those observations to apply a user-define list of functions (fun) applied to thethe underlying pixel values in y. In addition, the function will report on the linear distance traveled between endpoints (in meters) and the associated travel time (in minutes).

Value

A data.frame with statistics at each GPS observation. In addition the user defined statistics, the table will contain several entries describing the data used to calculate those statistics:

  • distance_traveled - Total distance traveled between all observations

  • elapsed_time - Time between the first and last observation

  • nr_observations - nr_observations

  • pixel_value - Pixel value at the main observation

See Also

timeDir

Examples

{

 require(terra)

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

 shortMove <- read.csv(system.file('extdata',
 'shortMove.csv', package="rsMove"))

 # convert observations to vector
 shortMove = vect(shortMove, geom=c("x","y"), crs="EPSG:32632")

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

 # construct target functions
 functions <- list(
    slope=function(i) lm(i~c(1:length(i)))$coefficients[2][[1]],
    mean=function(i) mean(i, na.rm=T),
    sd=function(i) sd(i, na.rm=T)
 )
 s.sample <- spaceDir(shortMove, r, obs.time, 30, 1, fun=functions)

}

RRemelgado/rsMove documentation built on June 3, 2024, 10:07 p.m.