Learn R Programming

prospectr (version 0.1.3)

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
interpolation method: 'linear' or 'spline'

Value

a matrix or vector with resampled values

See Also

resample2

Examples

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

Run the code above in your browser using DataLab