read.spc {soil.spec}R Documentation

Reads spectral spc-files into R

Description

read.spc reads binary spectral spc-files from a folder into R. The spectra can be made compatible (see details in make.comp) either to the first sample wavebands or to the standard wavebands of the ICRAF spectral lab. Information from the scanning method is gathered to check on spectral comparability. The default has been set to ICRAF spectral bands.

Usage

read.spc(loa = "", path = "", sav = "F", out = "Sm", save.as = "workspace", wn = "first")

Arguments

loa

a character giving the path name where the spc-files are stored. If "" (default), the spc-files are stored in the current working directory.

path

a character giving the path name where the function output shall be saved.

sav

a logical value indicating whether the function output shall be saved.

out

a character giving the function output name, in case sav is "T".

save.as

a character vector indicating the format of the saved output. "workspace" saves the function output named with out as workspace. "csv.file" saves the function output as csv-file.

wn

a character giving the way how the samples should be made compatible. If "first", all spectra are made compatible to the first read sample. if "ICRAF", all spectra are made compatible to the standard wavebands of the ICRAF spectral lab.

Details

Spectra from the near- and mid-infrared range can be read. In case the spc-files saved in loa comprise both ranges the function output is given separate for each range.

The function allows to read only spectra in one go, when they have the same material (e.g. soil or plant), were scanned with the same resolution and have the same zero filling. If there are still small differences in the number of wavebands, the spectra are made compatible depending on the argument wn. In case spectra with different materials shall be read, the user has to decide the material via graphical interface.

Value

read.spc returns a list with class "read.spc" containing the following components:

spectra

a numerical matrix containing the read spectra.

additional.information

a data frame containing some scanning method details.

raw.spectra

a data frame merging additional.information and spectra; columns 2 to 4 from the additional.information table are excluded to conform to the existing structure of library in existence

Author(s)

Andrew Sila and Thomas Terhoeven-Urselmans

Examples

## Not run: mir<-read.spc(loa="D:/AfSIS/spc files",sav="F",wn="ICRAF")
## Not run: raw<-mir$raw.spectra #To extract the object with both additional.information and spectra
## Not run: raw[1:4,1:4] #This gives a snapshot of the first four rows and the first columns

[Package soil.spec version 0.2.0 Index]