rsMove (version 0.2.8)

dataQuery: dataQuery

Description

Query environmental data for coordinate pairs using the nearest non NA value in time.

Usage

dataQuery(
  x,
  y,
  x.dates,
  y.dates,
  time.buffer,
  spatial.buffer = NULL,
  smooth.fun = NULL
)

Arguments

x

Object of class RasterStack, RasterBrick.

y

Object of class SpatialPoints or SpatialPointsDataFrame.

x.dates

Object of class Date with x observation dates.

y.dates

Object of class Date with y observation dates.

time.buffer

Two element vector with a temporal search buffer (expressed in days).

spatial.buffer

Spatial buffer size used to smooth the returned values. The unit depends on the spatial projection.

smooth.fun

Smoothing function applied with spatial.buffer.

Value

A data.frame with the selected values and their corresponding dates.

Details

Returns environmental variables from a multi-layer raster object x for a given set of coordinates (y) depending on the temporal distance between the observation dates (y.dates) and the date on which each layer in the environmental data was collected (x.dates). time.buffer controls the search for non-NA values in time and is adjusted to the observation date of each element in y. The user may also provide spatial.buffer to spatially smooth the selected environmental information. In this case, for each sample, the function will consider the neighboring pixels within the selected acquisition and apply a smoothing function defined by smooth.fun. If smooth.fun is not specified, a weighted mean will be returned by default.

See Also

sampleMove backSample

Examples

Run this code
# NOT RUN {
{

 require(raster)

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

 # read movement data
 data(shortMove)

 # raster dates
 file.name <- names(r.stk)
 x.dates <- as.Date(paste0(substr(file.name, 2, 5), '-',
 substr(file.name, 7, 8), '-', substr(file.name, 10, 11)))

 # sample dates
 y.dates <- as.Date(shortMove@data$date)

 # retrieve remote sensing data for samples
 rsQuery <- dataQuery(r.stk, shortMove, x.dates, y.dates, c(10,10))

}

# }

Run the code above in your browser using DataLab