dataQuery: dataQuery

Description Usage Arguments Details Value See Also Examples

View source: R/dataQuery.R

Description

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

Usage

1
2
3
4
5
6
7
8
9
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.

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.

Value

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

See Also

sampleMove backSample

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{

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

}

RRemelgado/rsMove documentation built on June 7, 2020, 5:12 p.m.