imgInt: imgInt

Description Usage Arguments Details Value See Also Examples

View source: R/imgInt.R

Description

Temporal linear interpolation of environmental data using a raster, SpatialPointsDataFrames or matrix/data.frame.

Usage

1
2
3
4
5
6
7
8
imgInt(
  x,
  x.dates,
  y,
  time.buffer,
  smooth = TRUE,
  smooth.fun = function(j) {     runmean2(as.numeric(j), 1) }
)

Arguments

x

Object of class RasterStack, RasterBrick or data.frame.

x.dates

Object of class Date with dates of x.

y

Object of class Date with target dates. Alternatively, a RasterStack or RasterBrick with julian days for each pixel.

time.buffer

A two-element vector with temporal search buffer (expressed in days).

smooth

Logical argument. Default is TRUE.

smooth.fun

Smoothing function. uses runmean2 by default.

Details

Wrapper for the function intime that performs a time-sensitive, linear interpolation of a multi-band raster. The output dates are specified by y and can differ from the dates of the input, specified by x.dates. time.buffer controls the search for dates to interpolate from specifying the maximum number of days that the selected data points can differ from the target date(s) in y. time.buffer is provided as a two element vector which limits the search in the past and future. If smooth is TRUE, the function will also smooth the interpolated time series. fun determines which function to use. By default, runmean2 is used whcih is an NA-sensitive, c++ implementation of a simple running mean.

Value

A RasterBrick or a data frame. If a RasterBrick, each layer represents a date in y. If a data.frame/matrix, columns represent dates and rows represent samples.

See Also

dataQuery timeDir spaceDir moveSeg

Examples

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

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

 # interpolate raster data to target dates
 out <- imgInt(r.stk[1:50,1:50,drop=FALSE], x.dates, as.Date("2013-08-10"), c(60,60))

}

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