get_reflectance: Get reflectance values

Description Usage Arguments Value Author(s) See Also Examples

View source: R/speclib_get_reflectance.R

Description

Returns weighted or unweighted reflectance values at wavelength position.

Usage

1
get_reflectance(spectra, wavelength, position, weighted = FALSE, ...)

Arguments

spectra

Object of class Speclib or data.frame with reflectance values.

wavelength

Vector with wavelength values. May be missing if spectra is object of class Speclib.

position

Numeric value passing the position of reflectance values to be returned in dimensions of the wavelength values.

weighted

Logical indicating if reflectance values should be interpolated to fit wavelength position. If FALSE the reflectance values of nearest neighbour to passed position are returned.

...

Arguments to be passed to specific functions. Currently ignored.

Value

A vector with reflectance values for each spectrum is returned. If position falls outside of spectral range of input values, NA values are returned.

Author(s)

Lukas Lehnert \& Hanna Meyer

See Also

spectra

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
data(spectral_data)

## Simulate multispectral sensor encompassing two bands 
## to show effect of weighted and unweighted modes
spectral_data_res <- spectralResampling(spectral_data, 
  sensor = data.frame(lb = c(400, 600), ub = c(500, 700)))

## Compare reflectance at 520 nm (in between both bands to 
## show the difference between weighted and unweighted modes)
weighted_reflectance   <- get_reflectance(spectral_data_res, 
                                          520, weighted = TRUE)
unweighted_reflectance <- get_reflectance(spectral_data_res, 
                                          520, weighted = FALSE)

## Plot result
plot(weighted_reflectance, unweighted_reflectance, 
     ylab = "Reflectance at 520 nm (unweighted)", 
     xlab = "Reflectance at 520 nm (weighted)")

Example output

Loading required package: raster
Loading required package: sp
Loading required package: rgdal
rgdal: version: 1.5-18, (SVN revision 1082)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 3.0.4, released 2020/01/28
Path to GDAL shared files: /usr/share/gdal
GDAL binary built with GEOS: TRUE 
Loaded PROJ runtime: Rel. 6.3.1, February 10th, 2020, [PJ_VERSION: 631]
Path to PROJ shared files: /usr/share/proj
Linking to sp version:1.4-4
To mute warnings of possible GDAL/OSR exportToProj4() degradation,
use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal.
Loading required package: signal

Attaching package:signalThe following object is masked frompackage:raster:

    resample

The following objects are masked frompackage:stats:

    filter, poly

Loading required package: caret
Loading required package: lattice
Loading required package: ggplot2
Loading required package: Boruta

###################################
  This is hsdar 1.0.3
  To get citation entry type
      'citation("hsdar")'
###################################

Attaching package:hsdarThe following object is masked frompackage:raster:

    nbands

hsdar documentation built on Aug. 4, 2020, 5:06 p.m.