rsMove (version 0.2.4)

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 or data.frame.

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

An object of class data.frame with the selected values and their corresponding dates.

Details

Returns environmental variables from a raster object for a given set of x and y coordinates depending on the temporal distance between the sample observation date (y.dates) and the date on which the environmental data was collected (x.dates). Within the buffer specified by time.buffer, the function will search for the nearest non NA value with the shortest temporal distance. The user can adjust time.buffer to control which pixels are considered in this analysis. For example, time.buffer can be set to c(30,0) prompting the function to ignore environmental information acquired after the sample observation date and limit the search to -30 days. If time.buffer is set to null all acquisitions are considered. 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. If x is a data.frame spatial.buffer and smooth.fun are ignored and x.dates should refer to each column.

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