Learn R Programming

prospectr (version 0.2.0)

resample: Resample spectral data

Description

Resample a data matrix, data.frame 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)

Arguments

X

numeric data.frame, matrix or vector to resample.

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

Value

a matrix or vector with resampled values.

See Also

resample2

Examples

Run this code
# NOT RUN {
data(NIRsoil)
wav <- as.numeric(colnames(NIRsoil$spc))
spc <- 1/10^NIRsoil$spc # conversion to reflectance
# increase spectral resolution by 2
resampled <- resample(spc, wav, seq(1100, 2498, 2)) 
dim(spc)
dim(resampled)
# }

Run the code above in your browser using DataLab