resample: Resample spectral data

View source: R/resample.R

resampleR Documentation

Resample spectral data

Description

Resample a data matrix or vector to new coordinates (e.g. band positions) using spline or linear interpolation. This function is a simple wrapper around approx and splinefun in base.

Usage

resample(X, wav, new.wav, interpol = "spline", ...)

Arguments

X

numeric matrix or vector to resample (optionally a data frame that can be coerced to a numerical matrix).

wav

a numeric vector giving the original band positions.

new.wav

a numeric vector giving the new band positions.

interpol

the interpolation method: 'linear' or 'spline' (default).

...

additional arguments to be passed to the splinefun function when interpol = 'spline'.

Value

a matrix or vector with resampled values.

Author(s)

Antoine Stevens and Leonardo Ramirez-Lopez

See Also

resample2

Examples

data(NIRsoil)
wav <- as.numeric(colnames(NIRsoil$spc))
# increase spectral resolution by 2
NIRsoil$spc_resampled <- resample(NIRsoil$spc, wav, seq(1100, 2498, 2))
dim(NIRsoil$spc)
dim(NIRsoil$spc_resampled)

l-ramirez-lopez/prospectr documentation built on Feb. 18, 2024, 7:52 a.m.