Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

resample

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

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)

prospectr

Miscellaneous Functions for Processing and Sample Selection of Spectroscopic Data

v0.2.1
MIT + file LICENSE
Authors
Antoine Stevens [aut, cre] (<https://orcid.org/0000-0002-1588-7519>), Leonardo Ramirez-Lopez [aut, cre] (<https://orcid.org/0000-0002-5369-5120>), Guillaume Hans [ctb] (<https://orcid.org/0000-0002-6503-5760>)
Initial release
2020-10-23

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.