├── .Rinstignore ├── ChangeLog ├── DESCRIPTION ├── MD5 ├── NAMESPACE ├── R ├── AAAClasses.R ├── ASD_functions.R ├── Boruta.R ├── HyperSpecRaster_methods.R ├── PROSAIL.R ├── PROSPECT.R ├── PROSPECTinvert.R ├── Spectra-class.R ├── USGS_speclib.R ├── blockwise_functions.R ├── caret_createDataPartition.R ├── caret_featurePlot.R ├── caret_gafs.R ├── caret_parameters.R ├── caret_preProcess.R ├── caret_predict.R ├── caret_rfe.R ├── caret_safs.R ├── caret_sbf.R ├── caret_train.R ├── caret_utils.R ├── continuum_clman.R ├── continuum_features.R ├── continuum_features_properties.R ├── continuum_transform.R ├── distMat3D_methods.R ├── distance.R ├── getFiniteNri.R ├── hsdardocs.R ├── multicore_funtions.R ├── nri.R ├── nri_attributes.R ├── nri_cor_test.R ├── nri_glm.R ├── nri_index.R ├── nri_lm.R ├── nri_methods.R ├── nri_multivariate.R ├── nri_plot.R ├── nri_print.R ├── nri_subset.R ├── nri_t_test.R ├── plot_HyperSpec_cube.R ├── raster-methods.R ├── rastermeta.R ├── read_header.R ├── rededge.R ├── smgm.R ├── soilindex.R ├── speclib.R ├── speclib_SI.R ├── speclib_apply.R ├── speclib_bandnames.R ├── speclib_differenciate.R ├── speclib_dim.R ├── speclib_fwhm.R ├── speclib_get_reflectance.R ├── speclib_id.R ├── speclib_index.R ├── speclib_mask.R ├── speclib_merge.R ├── speclib_plot.R ├── speclib_print.R ├── speclib_raster-methods.R ├── speclib_smooth.R ├── speclib_spectra.R ├── speclib_subset.R ├── speclib_usagehistory.R ├── speclib_wavelength.R ├── spectralInterpolation.R ├── spectral_resampling.R ├── spectral_resampling_gaussian.R ├── spectral_resampling_response.R ├── spectral_resampling_response_functions.R ├── spectral_resampling_sensorCharacteristics.R ├── sr.R ├── unmix.R ├── vegindex.R └── zzz.R ├── build ├── hsdar.pdf └── vignette.rds ├── data ├── Landsat_4_response.csv.gz ├── Landsat_5_response.csv.gz ├── Landsat_7_response.csv.gz ├── Landsat_8_response.csv.gz ├── Quickbird_response.csv.gz ├── RapidEye_response.csv.gz ├── Sentinel2A_response.csv.xz ├── Sentinel2B_response.csv.xz ├── WV_2_8_response.csv.gz ├── cancer_spectra.RData └── spectral_data.RData ├── inst ├── CITATION ├── COPYRIGHTS └── doc │ ├── Hsdar-intro.R │ ├── Hsdar-intro.Rnw │ ├── Hsdar-intro.pdf │ ├── References.Rnw │ └── References.pdf ├── man ├── Boruta.Rd ├── Clman-class.Rd ├── Clman-methods.Rd ├── DistMat3D-class.Rd ├── DistMat3D-methods.Rd ├── HyperSpecRaster-class.Rd ├── HyperSpecRaster.Rd ├── Nri-class.Rd ├── PROSAIL2R.Rd ├── PROSPECT2R.Rd ├── Specfeat-class.Rd ├── Speclib-class.Rd ├── USGS.Rd ├── addcp.Rd ├── applyDistMat3D.Rd ├── applySpeclib.Rd ├── attributes_speclib.Rd ├── bandnames.Rd ├── bdri.Rd ├── cancer_spectra.Rd ├── caret_createDataPartition-methods.Rd ├── caret_createFolds-methods.Rd ├── caret_createResample-methods.Rd ├── caret_featurePlot-methods.Rd ├── caret_gafs.Rd ├── caret_preProcess-methods.Rd ├── caret_rfe.Rd ├── caret_safs.Rd ├── caret_setPredictor.Rd ├── caret_setResponse.Rd ├── caret_sfb.Rd ├── caret_showCaretParameters.Rd ├── caret_train-methods.Rd ├── checkhull.Rd ├── cor.test.normalized.ratio.index.Rd ├── cubePlot.Rd ├── cut.specfeat.Rd ├── deletecp.Rd ├── derivative_speclib.Rd ├── dim_speclib.Rd ├── dist_speclib.Rd ├── feature_properties.Rd ├── figures │ ├── classes.pdf │ ├── classes.png │ ├── classes.svg │ ├── rededge.pdf │ └── rededge.png ├── get.gaussian.response.Rd ├── getNRI.Rd ├── get_reflectance.Rd ├── getcp.Rd ├── glm.normalized.ratio.index.Rd ├── hsdar-package.Rd ├── hsdar_parallel.Rd ├── hsdardocs.Rd ├── id_speclib.Rd ├── makehull.Rd ├── mask.Rd ├── meanfilter.Rd ├── merge_speclib.Rd ├── normalized.ratio.index-methods.Rd ├── normalized.ratio.index.Rd ├── normalized.ratio.index.best.perfomance.Rd ├── plot.glm.normalized.ratio.index.Rd ├── plot.specfeat.Rd ├── plot.speclib.Rd ├── postprocess_ASD.Rd ├── predictHyperspec.Rd ├── raster-methods.Rd ├── rastermeta.Rd ├── read.header.Rd ├── read_ASD.Rd ├── rededge.Rd ├── sensorCharacteristics.Rd ├── simple.ratio.index.Rd ├── smgm.Rd ├── smooth_speclib.Rd ├── soilindex.Rd ├── specfeat.Rd ├── speclib.Rd ├── speclib_indexing.Rd ├── speclib_raster_methods.Rd ├── spectra.Rd ├── spectralInterpolation.Rd ├── spectralResampling.Rd ├── spectral_data.Rd ├── subset_nri.Rd ├── subset_speclib.Rd ├── t.test.nri.Rd ├── transform.Rd ├── unmix.Rd ├── updatecl.Rd ├── usagehistory.Rd ├── vegindex.Rd └── wavelength.Rd ├── src ├── LIDF.f90 ├── MODULE_PRO4SAIL.f90 ├── Makevars ├── Makevars.win ├── PRO4SAIL.f90 ├── adminparallel.f90 ├── apply_response.f90 ├── bandDepthRatioIndices.f90 ├── c2lablas.f ├── c2lablas.h ├── checkhull.f90 ├── dataSpec_P5B_PROSAIL.f90 ├── dataSpec_P5B_PROSPECT.f90 ├── dataSpec_PDB_PROSPECT.f90 ├── differenciate.f90 ├── dladgen.f ├── interpolate.f90 ├── localMaxima.f90 ├── main_PROSAIL.f90 ├── main_PROSPECT_5B.f90 ├── main_PROSPECT_D.f90 ├── meanfilter.f90 ├── prospect_5B.f90 ├── prospect_DB.f90 ├── pt2f.c ├── recursiveNRI.f90 ├── recursiveSR.f90 ├── registerDynamicSymbol.c ├── sam.f90 ├── smgm.f90 ├── suh.f90 ├── tav_abs_PROSPECT_5B.f90 ├── tav_abs_PROSPECT_D.f90 ├── unmix.c └── volscatt.f90 └── vignettes ├── Hsdar-intro.Rnw ├── References.Rnw └── hsdar.bib /.Rinstignore: -------------------------------------------------------------------------------- 1 | inst/doc/References.tex 2 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/ChangeLog -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: hsdar 2 | Type: Package 3 | Title: Manage, Analyse and Simulate Hyperspectral Data 4 | Version: 1.0.4 5 | Date: 2022-02-20 6 | Authors@R: c( 7 | person("Lukas W.", "Lehnert", role = c("cre", "aut"), 8 | email = "lukaslehnert@googlemail.com", 9 | comment = c(ORCID = "0000-0002-5229-2282")), 10 | person("Hanna", "Meyer", role = "ctb"), 11 | person("Joerg", "Bendix", role = "ctb") 12 | ) 13 | Maintainer: Lukas W. Lehnert 14 | Depends: R (>= 3.3.1), raster (>= 2.5-8), rgdal (>= 1.1-10), signal, 15 | methods, caret, Boruta 16 | Suggests: rgl (>= 0.98.1), RCurl, foreach, asdreader 17 | Description: Transformation of reflectance spectra, calculation of vegetation indices and red edge parameters, spectral resampling for hyperspectral remote sensing, simulation of reflectance and transmittance using the leaf reflectance model PROSPECT and the canopy reflectance model PROSAIL. 18 | License: GPL 19 | LazyLoad: yes 20 | BuildVignettes: yes 21 | Copyright: see file COPYRIGHTS 22 | NeedsCompilation: yes 23 | Packaged: 2022-02-21 11:25:39 UTC; lehnert 24 | Author: Lukas W. Lehnert [cre, aut] (), 25 | Hanna Meyer [ctb], 26 | Joerg Bendix [ctb] 27 | Repository: CRAN 28 | Date/Publication: 2022-02-21 12:20:02 UTC 29 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | import( 2 | raster, 3 | rgdal, 4 | methods, 5 | caret, 6 | Boruta 7 | ) 8 | importFrom("graphics", "legend", "par", "points", "polygon", "rasterImage", "rect", "title") 9 | importFrom("grDevices", "chull", "colorRamp", "dev.off", "hcl", "heat.colors", "palette", "png", "rgb") 10 | importFrom("stats", "approx", "as.dist", "as.formula", "dist", "dnorm", "glm", "lm", "lowess", "sd", "spline", "splinefun", "terms", "update.formula", "optim") 11 | importFrom("utils", "data") 12 | importFrom("signal", sgolay) 13 | importFrom("signal", sgolayfilt) 14 | importFrom("stats", "cor", "na.fail") 15 | importFrom("utils", "read.table") 16 | 17 | useDynLib(hsdar, .registration = TRUE) 18 | 19 | exportPattern("^[[:alpha:]]+") 20 | exportMethods( 21 | "apply", 22 | "SI", 23 | "SI<-", 24 | "as.array", 25 | "as.matrix", 26 | "[<-", 27 | "[", 28 | "$", 29 | "cor.test", 30 | "dim", 31 | "distMat3D", 32 | "getValuesBlock", 33 | "HyperSpecRaster", 34 | "initialize", 35 | "mask<-", 36 | "merge", 37 | "ncol", 38 | "n_features", 39 | "nrow", 40 | "plot", 41 | "print", 42 | "show", 43 | "speclib", 44 | "spectra<-", 45 | "spectra", 46 | "subset", 47 | "t.test", 48 | "wavelength<-", 49 | "wavelength", 50 | "writeStart", 51 | "writeValues" 52 | ) 53 | exportClasses( 54 | "Clman", 55 | "DistMat3D", 56 | "HyperSpecRaster", 57 | "Nri", 58 | "Specfeat", 59 | "Speclib" 60 | ) 61 | -------------------------------------------------------------------------------- /R/ASD_functions.R: -------------------------------------------------------------------------------- 1 | .getcorfac <- function(crossing, x) 2 | return(spectra(x)[,crossing + 1] - (2* spectra(x)[,crossing] - spectra(x)[,crossing - 1])) 3 | 4 | .applcorfac <- function(cor_fac, crossing, x) 5 | { 6 | cor_fac <- c(list(rep.int(0, nspectra(x))), cor_fac) 7 | cor_fac_cu <- cor_fac[[1]] 8 | crossing <- c(0, crossing, nbands(x)) 9 | 10 | spec <- spectra(x) 11 | for (i in 1:length(cor_fac)) 12 | { 13 | cor_fac_cu <- cor_fac_cu + cor_fac[[i]] 14 | spec[,c((crossing[i]+1):crossing[i+1])] <- spec[,c((crossing[i]+1):crossing[i+1])] - cor_fac_cu 15 | } 16 | spec[spec < 0] <- 0 17 | return(spec) 18 | } 19 | 20 | read.ASD <- function(f, type = "reflectance", ...) 21 | { 22 | if (length(f) > 1) 23 | { 24 | for (i in 1:length(f)) 25 | { 26 | if (i > 1) 27 | { 28 | dat <- merge(dat, read.ASD(f[i], type = type, ...)) 29 | } else { 30 | dat <- read.ASD(f[i], type = type, ...) 31 | } 32 | } 33 | usagehistory(dat) <- NULL 34 | usagehistory(dat) <- paste("Spectra from", length(f), "ASD-files read") 35 | return(dat) 36 | } 37 | if (!requireNamespace("asdreader", quietly = TRUE)) 38 | stop("Library 'asdreader' is required to read ASD file(s)") 39 | 40 | dat_raw <- asdreader::get_spectra(f, type = type) 41 | dat <- speclib(dat_raw, as.numeric(attr(dat_raw, "dimnames")[[2]])) 42 | SI(dat) <- data.frame(file = attr(dat_raw, "dimnames")[[1]], stringsAsFactors = FALSE) 43 | return(dat) 44 | } 45 | 46 | postprocessASD <- function(x, reference, removeCrossings = TRUE, correctReflectance = TRUE) 47 | { 48 | if (removeCrossings) 49 | { 50 | crossings <- c(1000, 1800) 51 | crossings <- sapply(crossings, function(x, wv) which.min(abs(wv - x)), wavelength(x)) 52 | cor_fac <- lapply(as.list(crossings), .getcorfac, x) 53 | spectra(x) <- .applcorfac(cor_fac, crossings, x) 54 | } 55 | 56 | if (correctReflectance) 57 | { 58 | if (nspectra(reference) != 1) 59 | { 60 | stop("Reference speclib must contain exactly one spectrum") 61 | } 62 | spectra(x) <- t(apply(spectra(x), 1, function(v, r) return(v*r), spectra(reference))) 63 | } 64 | 65 | if (all(c(removeCrossings, correctReflectance))) 66 | { 67 | usagehistory(x) <- "Channel crossing removed and reflectance corrected" 68 | } else { 69 | if (removeCrossings) 70 | { 71 | usagehistory(x) <- "Channel crossing removed" 72 | } else { 73 | usagehistory(x) <- "Reflectance corrected" 74 | } 75 | } 76 | return(x) 77 | } 78 | -------------------------------------------------------------------------------- /R/Spectra-class.R: -------------------------------------------------------------------------------- 1 | setMethod("ncol", signature(x = ".Spectra"), 2 | function(x) 3 | if (x@fromRaster) 4 | { 5 | return(x@spectra_ra@data@nlayers) 6 | } else { 7 | return(ncol(x@spectra_ma)) 8 | } 9 | ) 10 | 11 | setMethod("nrow", signature(x = ".Spectra"), 12 | function(x) 13 | if (x@fromRaster) 14 | { 15 | return(x@spectra_ra@nrows * x@spectra_ra@ncols) 16 | } else { 17 | return(nrow(x@spectra_ma)) 18 | } 19 | ) 20 | 21 | -------------------------------------------------------------------------------- /R/caret_createDataPartition.R: -------------------------------------------------------------------------------- 1 | if (!isGeneric("createDataPartition")) { 2 | setGeneric("createDataPartition") 3 | } 4 | 5 | if (!isGeneric("createResample")) { 6 | setGeneric("createResample") 7 | } 8 | 9 | if (!isGeneric("createFolds")) { 10 | setGeneric("createFolds") 11 | } 12 | 13 | if (!isGeneric("createMultiFolds")) { 14 | setGeneric("createMultiFolds") 15 | } 16 | 17 | setMethod("createDataPartition", signature(y = ".CaretHyperspectral"), 18 | definition = function(y, 19 | times = 1, 20 | p = 0.5, 21 | list = TRUE, 22 | groups = min(5, length(y))) 23 | { 24 | return(createDataPartition(.getResponseVar(y, 25 | advice = c("createDataPartition", "setResponse")), 26 | times = times, 27 | p = p, 28 | list = list, 29 | groups = groups)) 30 | 31 | }) 32 | 33 | setMethod("createResample", signature(y = ".CaretHyperspectral"), 34 | definition = function(y, 35 | times = 10, 36 | list = TRUE) 37 | { 38 | return(createResample(.getResponseVar(y, 39 | advice = c("createResample", "setResponse")), 40 | times = times, 41 | list = list 42 | )) 43 | 44 | }) 45 | 46 | setMethod("createFolds", signature(y = ".CaretHyperspectral"), 47 | definition = function(y, 48 | k = 10, 49 | list = TRUE, 50 | returnTrain = FALSE) 51 | { 52 | return(createFolds(.getResponseVar(y, 53 | advice = c("createFolds", "setResponse")), 54 | k = k, 55 | list = list, 56 | returnTrain = returnTrain 57 | )) 58 | 59 | }) 60 | 61 | setMethod("createMultiFolds", signature(y = ".CaretHyperspectral"), 62 | definition = function(y, 63 | k = 10, 64 | times = 5) 65 | { 66 | return(createMultiFolds(.getResponseVar(y, 67 | advice = c("createMultiFolds", "setResponse")), 68 | times = times, 69 | k = k 70 | )) 71 | 72 | }) 73 | 74 | 75 | -------------------------------------------------------------------------------- /R/caret_featurePlot.R: -------------------------------------------------------------------------------- 1 | if (!isGeneric("train")) { 2 | setGeneric("train") 3 | } 4 | if (!isGeneric("featurePlot")) { 5 | setGeneric("featurePlot") 6 | } 7 | 8 | setMethod("featurePlot", signature(x = ".CaretHyperspectral"), 9 | definition = function(x, 10 | y, 11 | ...) 12 | { 13 | y_missing <- missing(y) 14 | 15 | if (y_missing) 16 | { 17 | y <- .getResponseVar(x, 18 | advice = c("train", "setResponse", 19 | "This is only required if you do not specify 'y'.")) 20 | } 21 | 22 | useSIAsPredicants <- !is.na(.getPredicantVar(x, stopifmissing = FALSE))[1] 23 | 24 | all_vals <- as.data.frame(x) 25 | 26 | if (useSIAsPredicants) 27 | { 28 | addVar <- .getPredicantVar(x) 29 | all_vals <- cbind(all_vals, addVar) 30 | } 31 | 32 | x <- all_vals 33 | return(featurePlot(x = x, y = y, ...)) 34 | }) 35 | -------------------------------------------------------------------------------- /R/caret_preProcess.R: -------------------------------------------------------------------------------- 1 | if (!isGeneric("preProcess")) { 2 | setGeneric("preProcess") 3 | } 4 | 5 | if (!isGeneric("predict")) { 6 | setGeneric("predict") 7 | } 8 | 9 | setMethod("preProcess", signature(x = ".CaretHyperspectral"), 10 | definition = function(x, ...) 11 | { 12 | x <- .getAllPredictors(x, NA) 13 | x <- x[,sapply(1:ncol(x), 14 | function(i, data) is.numeric(data[,i]), x)] 15 | x <- preProcess(x, ...) 16 | return(new(".preProcessHyperspectral", preProcess = x)) 17 | }) 18 | 19 | setMethod("predict", signature(object = ".preProcessHyperspectral"), 20 | definition = function(object, newdata, ...) 21 | { 22 | object <- object@preProcess 23 | if (!(class(newdata)[1] %in% .getCaretCompatibleClasses())) 24 | return(predict(object, newdata = newdata, ...)) 25 | 26 | backup <- newdata 27 | newdata_all <- .getAllPredictors(newdata, NA) 28 | is_num <- sapply(1:ncol(newdata_all), 29 | function(i, data) is.numeric(data[,i]), newdata_all) 30 | newdata <- newdata_all[,is_num] 31 | 32 | predicted <- predict(object, newdata = newdata, ...) 33 | 34 | newdata_all[,is_num] <- predicted 35 | 36 | predicted_spectral <- newdata_all[,attr(newdata_all, "spectral")] 37 | if (attr(newdata_all, "useattributes")) 38 | SI(backup)[,.getCaretParameter(object, "predictor")] <- newdata_all[,attr(newdata_all, "spectral")*(-1)] 39 | 40 | if (class(backup)[1] == "Speclib") 41 | spectra(backup) <- as.matrix(predicted_spectral) 42 | 43 | if (class(backup)[1] == "Nri") ### Konvertierung nicht optimal! 44 | { 45 | values <- numeric(length = length(backup@nri@values)) 46 | values[] <- NA 47 | incr <- length(backup@nri@values)/nrow(predicted_spectral) 48 | for (i in 1:ncol(predicted_spectral)) 49 | { 50 | index <- seq(i, length(values), incr) 51 | values[index] <- predicted_spectral[,i] 52 | } 53 | backup@nri <- distMat3D(values, ncol = ncol(backup@nri), nlyr = nrow(predicted_spectral)) 54 | } 55 | return(backup) 56 | }) 57 | 58 | -------------------------------------------------------------------------------- /R/caret_train.R: -------------------------------------------------------------------------------- 1 | if (!isGeneric("train")) { 2 | setGeneric("train") 3 | } 4 | # if (!isGeneric("train.formula")) { 5 | # setGeneric("train.formula") 6 | # } 7 | 8 | setMethod("train", signature(x = ".CaretHyperspectral"), 9 | definition = function(x, 10 | y, 11 | ...) 12 | { 13 | y_missing <- missing(y) 14 | 15 | if (y_missing) 16 | { 17 | y <- .getResponseVar(x, 18 | advice = c("train", "setResponse", 19 | "This is only required if you do not specify 'y'.")) 20 | } 21 | 22 | useSIAsPredicants <- !is.na(.getPredicantVar(x, stopifmissing = FALSE))[1] 23 | 24 | if (class(x)[1] == "Nri") 25 | { 26 | all_vals <- as.data.frame(x, na.rm = TRUE) 27 | } else { 28 | all_vals <- as.data.frame(x) 29 | } 30 | 31 | if (useSIAsPredicants) 32 | { 33 | addVar <- .getPredicantVar(x) 34 | all_vals <- cbind(all_vals, addVar) 35 | } 36 | 37 | x <- all_vals 38 | return(train(x = x, y = y, ...)) 39 | }) 40 | 41 | # setMethod("train.formula", signature(form = "formula", data = "Speclib"), 42 | # definition = function(form, 43 | # data, 44 | # ...) 45 | # { 46 | # if (is.null(bandnames(spectral_data))) 47 | # bandnames(spectral_data) <- paste("V", c(1:nbands(data)), sep = "") 48 | # data <- cbind(SI(data), as.data.frame(data)) 49 | # return(train.formula(form = form, data = data, ...)) 50 | # }) 51 | -------------------------------------------------------------------------------- /R/caret_utils.R: -------------------------------------------------------------------------------- 1 | 2 | .getAttrParameters <- function() 3 | c("response", "predictor") 4 | 5 | .getCaretCompatibleClasses <- function() 6 | c("Speclib", "Nri", "Specfeat") 7 | 8 | setClassUnion(".CaretHyperspectral", .getCaretCompatibleClasses()) 9 | 10 | setOldClass("preProcess") 11 | 12 | setClass(".preProcessHyperspectral", 13 | representation( 14 | preProcess = "preProcess" 15 | ), 16 | prototype( 17 | preProcess = list() 18 | ) 19 | ) 20 | 21 | setMethod("show", ".preProcessHyperspectral", function(object) show(object@preProcess)) -------------------------------------------------------------------------------- /R/getFiniteNri.R: -------------------------------------------------------------------------------- 1 | getFiniteNri <- function(x) 2 | { 3 | if (class(x)[1] != "Nri") 4 | stop("'x' must be of class Nri") 5 | 6 | 7 | result <- apply(x$nri, 1, FUN = function(i) return(all(is.finite(i)))) 8 | 9 | 10 | result <- distMat3D(result*1, ncol = ncol(x@nri), nlyr = 1) 11 | 12 | result <- as.matrix(result) 13 | 14 | wl1 <- matrix(data=rep.int(c(1:dim(result)[1]),dim(result)[1]), 15 | nrow=dim(result)[1], ncol=dim(result)[1], byrow = FALSE) 16 | wl2 <- matrix(data=rep.int(c(1:dim(result)[1]),dim(result)[1]), 17 | nrow=dim(result)[1], ncol=dim(result)[1], byrow = TRUE) 18 | 19 | 20 | 21 | relevant <- data.frame(dim1=as.vector(wl1[result==1 & is.finite(result) & lower.tri(result)]), 22 | dim2=as.vector(wl2[result==1 & is.finite(result) & lower.tri(result)])) 23 | relevant <- data.frame(Band_1=x$wavelength[relevant$dim1], Band_2=x$wavelength[relevant$dim2]) 24 | return(list(Indices=relevant, Models=NULL)) 25 | } 26 | -------------------------------------------------------------------------------- /R/hsdardocs.R: -------------------------------------------------------------------------------- 1 | hsdardocs <- function(doc) 2 | { 3 | if (doc == "References.pdf") 4 | { 5 | doc <- file.path(system.file(package = "hsdar"), "doc", doc) 6 | if (.Platform$OS.type == "windows") 7 | { 8 | shell.exec(doc) 9 | } else { 10 | system(paste(getOption("pdfviewer"), doc, "&")) 11 | } 12 | } 13 | if (toupper(doc) == "COPYRIGHT") 14 | { 15 | doc <- file.path(system.file(package = "hsdar"), "COPYRIGHTS") 16 | if (.Platform$OS.type == "windows") 17 | { 18 | file.show(doc) 19 | } else { 20 | system(paste(getOption("pager"), doc, "&")) 21 | } 22 | } 23 | if (doc == "Hsdar-intro.pdf") 24 | { 25 | doc <- file.path(system.file(package = "hsdar"), "doc", doc) 26 | if (.Platform$OS.type == "windows") 27 | { 28 | shell.exec(doc) 29 | } else { 30 | system(paste(getOption("pdfviewer"), doc, "&")) 31 | } 32 | } 33 | } 34 | 35 | 36 | .applyInHelp <- function(fun_name, usage) 37 | { 38 | if (usage) 39 | { 40 | if ("simplify" %in% names(formals(base::apply))) 41 | { 42 | return(paste0("\\usage{\n", 43 | "\\S4method{apply}{", fun_name, "}(X, MARGIN, FUN, ..., simplify = TRUE)\n", 44 | "}")) 45 | return(", simplify = TRUE)") 46 | } else { 47 | return(paste0("\\usage{\n", 48 | "\\S4method{apply}{", fun_name, "}(X, MARGIN, FUN, ...)\n", 49 | "}")) 50 | } 51 | } else { 52 | if ("simplify" %in% names(formals(base::apply))) 53 | { 54 | return("}\n\\item{simplify}{Currently ignored") 55 | } else { 56 | return("") 57 | } 58 | } 59 | } 60 | 61 | 62 | 63 | 64 | # .applyInHelp <- function(fun_name, usage) 65 | # { 66 | # if (usage) 67 | # { 68 | # if ("simplify" %in% names(formals(base::apply))) 69 | # { 70 | # return(paste0("\\S4method{apply}{", fun_name, "}(X, MARGIN, FUN, ..., simplify = TRUE)")) 71 | # } else { 72 | # return(paste0("\\S4method{apply}{", fun_name, "}(X, MARGIN, FUN, ...)")) 73 | # } 74 | # } else { 75 | # return("\\item{simplify}{Currently ignored}") 76 | # } 77 | # } 78 | -------------------------------------------------------------------------------- /R/multicore_funtions.R: -------------------------------------------------------------------------------- 1 | hsdar_parallel <- function() 2 | { 3 | sort(c("transformSpeclib", "glm.nri", "noiseFiltering", "apply" 4 | )) 5 | } 6 | 7 | .process_parallel <- function() 8 | { 9 | process_parallel <- list(parallel = any(search() %in% c("package:doMC", "package:doMPI")), dofun = NULL, donestedfun = NULL) 10 | if (process_parallel[[1]]) 11 | { 12 | if (.getParallel()) 13 | { 14 | loadNamespace("foreach") 15 | process_parallel$dofun <- if (foreach::getDoParWorkers() > 1) foreach::`%dopar%` else foreach::`%do%` 16 | process_parallel$donestedfun <- foreach::`%:%` 17 | } else { 18 | process_parallel[[1]] <- FALSE 19 | } 20 | } 21 | return(process_parallel) 22 | } 23 | 24 | .getParallel <- function() 25 | { 26 | res <- .Fortran("adminparallel", 27 | flag = as.integer(1), 28 | process = as.integer(0), 29 | PACKAGE = "hsdar" 30 | )$process 31 | return(res == -1) 32 | } 33 | 34 | 35 | .restoreParallel <- function() 36 | { 37 | res <- .Fortran("adminparallel", 38 | flag = as.integer(0), 39 | process = as.integer(0), 40 | PACKAGE = "hsdar" 41 | ) 42 | } 43 | -------------------------------------------------------------------------------- /R/nri.R: -------------------------------------------------------------------------------- 1 | nri <- function( 2 | x, 3 | b1, 4 | b2, 5 | recursive = FALSE, 6 | bywavelength = TRUE 7 | ) 8 | { 9 | if (!is.speclib(x)) 10 | stop("x must be of class 'Speclib'") 11 | 12 | range.of.wavelength <- x$fwhm 13 | 14 | reflectance <- spectra(x) 15 | wavelength <- wavelength(x) 16 | 17 | 18 | if (recursive) 19 | { 20 | 21 | if (inherits(nrow(reflectance) * (sum(1:length(wavelength))-length(wavelength)), "error")) 22 | { 23 | stop("Number of Samples*(number of wavelengths^2) exceeds maximum 24 | vector size of 2^31-1") 25 | } 26 | 27 | nri_dat <- single(length = nrow(reflectance) * (sum(1:length(wavelength))-length(wavelength))) 28 | result <- .Fortran("recursive_nri", 29 | nwl = as.integer(length(wavelength)), 30 | nspec = as.integer(nrow(reflectance)), 31 | reflectance = as.single(as.matrix(reflectance)), 32 | nri = nri_dat, 33 | nri_length = as.integer(nrow(reflectance) * 34 | (sum(1:length(wavelength))-length(wavelength))), 35 | PACKAGE = "hsdar" 36 | ) 37 | 38 | result <- distMat3D(as.numeric(result$nri), length(wavelength), nrow(reflectance)) 39 | result <- new("Nri", nri = result, fwhm = range.of.wavelength, 40 | wavelength = wavelength, 41 | dimnames = list(Band_1 = paste("B_", wavelength, sep = ""), 42 | Band_2 = paste("B_", wavelength, sep = ""), 43 | Sample = idSpeclib(x)), 44 | SI = x@SI 45 | ) 46 | if (!is.null(attr(x, "caretParameters"))) 47 | attr(result, "caretParameters") <- attr(x, "caretParameters") 48 | result@usagehistory <- c(x@usagehistory, "NRI values calculated") 49 | } else { 50 | b1 <- as.vector(unlist(b1)) 51 | b2 <- as.vector(unlist(b2)) 52 | 53 | stopifnot(length(b1) == length(b2)) 54 | 55 | b1 <- b1 * .ConvWlBwd(x@wlunit) 56 | b2 <- b2 * .ConvWlBwd(x@wlunit) 57 | 58 | if (length(b1) > 1) 59 | { 60 | res <- apply(matrix(1:length(b1), ncol = 1), 1, 61 | FUN = function(i, x, b1, b2, bywavelength) 62 | { 63 | index <- nri(x, b1 = b1[i], b2 = b2[i], bywavelength = bywavelength) 64 | return(index) 65 | }, x, b1, b2, bywavelength) 66 | colnames(res) <- paste("B", b1, "B", b2, sep = "_") 67 | rownames(res) <- idSpeclib(x) 68 | return(res) 69 | } 70 | if (bywavelength) 71 | { 72 | posb1 <- which(wavelength==b1) 73 | posb2 <- which(wavelength==b2) 74 | } else { 75 | posb1 <- b1 76 | posb2 <- b2 77 | } 78 | result <- (reflectance[,posb1]-reflectance[,posb2])/(reflectance[,posb1]+reflectance[,posb2]) 79 | if (class(result)[1] == "data.frame") 80 | names(result)<-"NRI" 81 | } 82 | return(result) 83 | } 84 | -------------------------------------------------------------------------------- /R/nri_attributes.R: -------------------------------------------------------------------------------- 1 | setMethod("SI", signature(object = "Nri", i = "missing", j = "missing"), 2 | function(object, i, j) 3 | return(.SI(object@SI)) 4 | ) 5 | 6 | setMethod("SI", signature(object = "Nri", i = "ANY", j = "missing"), 7 | function(object, i, j) 8 | return(object@SI[i,]) 9 | ) 10 | 11 | setMethod("SI", signature(object = "Nri", i = "missing", j = "ANY"), 12 | function(object, i, j) 13 | return(object@SI[,j]) 14 | ) 15 | 16 | setMethod("SI", signature(object = "Nri", i = "ANY", j = "ANY"), 17 | function(object, i, j) 18 | return(object@SI[i,j]) 19 | ) 20 | 21 | 22 | setReplaceMethod("SI", signature(object = "Nri", value = "matrix"), 23 | function(object, value) 24 | { 25 | object@SI <- new(".SI", value) 26 | return(object) 27 | } 28 | ) 29 | 30 | setReplaceMethod("SI", signature(object = "Nri", value = "data.frame"), 31 | function(object, value) 32 | { 33 | object@SI <- new(".SI", value) 34 | return(object) 35 | } 36 | ) 37 | 38 | setReplaceMethod("SI", signature(object = "Nri", value = "ANY"), 39 | function(object, value) 40 | { 41 | object@SI <- new(".SI", value) 42 | return(object) 43 | } 44 | ) 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /R/nri_cor_test.R: -------------------------------------------------------------------------------- 1 | setMethod("cor.test", signature(x = "Nri"), 2 | function(x, y, ...) 3 | { 4 | cor_apply_lh <- function(response, ...) 5 | { 6 | predictor <- get("predictor", envir= environment_apply) 7 | t_res <- cor.test(x = predictor, y = response, ...) 8 | return(c(t_res$p.value, t_res$estimate)) 9 | } 10 | cor_apply_rh <- function(predictor, ...) 11 | { 12 | response <- get("response", envir= environment_apply) 13 | t_res <- cor.test(x = predictor, y = response, ...) 14 | return(c(t_res$p.value, t_res$estimate)) 15 | } 16 | cor_apply_both <- function(xy, ...) 17 | { 18 | t_res <- cor.test(x = xy[1:(length(xy)/2)], y = xy[(length(xy)/2+1):length(xy)], ...) 19 | return(c(t_res$p.value, t_res$estimate)) 20 | } 21 | 22 | if (class(x)[1] == "Nri") 23 | { 24 | if (class(y)[1] == "Nri") 25 | { 26 | nri_response <- NA 27 | for (i in 1:length(dim(x$nri))) 28 | if (dim(x$nri)[i]!=dim(y$nri)[i]) 29 | stop("Dimensions of nri values in x and y differ") 30 | } else { 31 | nri_response <- FALSE 32 | } 33 | nri_data <- x 34 | } else { 35 | if (class(y)[1] == "Nri") 36 | { 37 | nri_response <- TRUE 38 | nri_data <- y 39 | } else { 40 | stop("Could not determine which variable contains nri-values") 41 | } 42 | } 43 | 44 | if (is.na(nri_response)) 45 | { 46 | xy <- new("DistMat3D", values = c(x$nri, y$nri), 47 | nlyr = dim(x$nri)[3] + dim(y$nri)[3], 48 | ncol = dim(x$nri)[1]) 49 | res <- new("Nri", nri = xy, fwhm = x@fwhm, 50 | wavelength = x@wavelength, 51 | dimnames = list(Band_1 = x@dimnames[[1]], 52 | Band_2 = x@dimnames[[1]], 53 | Sample = c(x@dimnames[[1]], 54 | y@dimnames[[1]]))) 55 | cor_data <- apply(xy, MARGIN = c(1, 2), FUN = cor_apply_both, ...) 56 | } else { 57 | if (nri_response) 58 | { 59 | res <- y 60 | response <- y$nri 61 | environment_apply <- new.env(parent = .GlobalEnv) 62 | assign("predictor", x, environment_apply) 63 | 64 | cor_data <- apply(response, MARGIN = c(1, 2), FUN = cor_apply_lh, ...) 65 | } else { 66 | res <- x 67 | predictor <- x$nri 68 | 69 | environment_apply <- new.env(parent = .GlobalEnv) 70 | assign("response", y, environment_apply) 71 | 72 | cor_data <- apply(predictor, MARGIN = c(1, 2), FUN = cor_apply_rh, ...) 73 | } 74 | } 75 | 76 | final <- list(p.value = new("DistMat3D", values = cor_data[1,], 77 | ncol = dim(x$nri)[1], nlyr = 1), 78 | estimate = new("DistMat3D", values = cor_data[2,], 79 | ncol = dim(x$nri)[1], nlyr = 1) 80 | ) 81 | attr(final,"is.predictor.nri") <- nri_response 82 | attr(final,"function") <- "cor.test" 83 | res@multivariate <- final 84 | return(res) 85 | } 86 | ) 87 | -------------------------------------------------------------------------------- /R/nri_index.R: -------------------------------------------------------------------------------- 1 | setMethod("[", "Nri", 2 | function(x, i, ...) 3 | { 4 | x@nri <- distMat3D(x@nri[,,i], lower_tri = TRUE) 5 | if (ncol(SI(x)) == 1) 6 | { 7 | nam <- names(SI(x)) 8 | tmp <- data.frame(XXX = SI(x, i = i)) 9 | names(tmp) <- nam 10 | SI(x) <- tmp 11 | } else { 12 | SI(x) <- SI(x, i = i) 13 | } 14 | return(x) 15 | }) 16 | -------------------------------------------------------------------------------- /R/nri_print.R: -------------------------------------------------------------------------------- 1 | .print.glmnri <- function(x, ...) 2 | { 3 | fun_name = if (is.null(attr(x,"function"))) "glm" else attr(x,"function") 4 | 5 | mc <- as.character(attr(x, "call")) 6 | 7 | cat(paste("Call: ", fun_name, "(", sep = "")) 8 | cat(paste(mc[2], mc[1])) 9 | cat(paste("",mc[3])) 10 | cat(")\n\n") 11 | 12 | dim1 <- vector(mode = "numeric", length = 0) 13 | dim2 <- vector(mode = "numeric", length = 0) 14 | dim3 <- vector(mode = "numeric", length = 0) 15 | cat("Models contain following parameters:\n") 16 | for (i in 1:length(names(x))) 17 | { 18 | cat(paste("[[", i, "]] ", names(x)[i], "\n", sep="")) 19 | dim1 <- c(dim1, dim(x[[i]])[1]) 20 | dim2 <- c(dim2, dim(x[[i]])[2]) 21 | dim3 <- c(dim3, dim(x[[i]])[3]) 22 | } 23 | 24 | if (any(c(any(dim1 != dim1[1]),any(dim2 != dim2[1]),any(dim2 != dim2[1])))) 25 | { 26 | cat("Dimensions of parameter:\n") 27 | for (i in 1:length(names(x))) 28 | cat(paste(" ", names(x)[i], ": ", dim1[i], ", ", dim2[i], ", ", dim3[i], "\n", sep = "")) 29 | 30 | } else { 31 | cat(paste("Dimension of each parameter: ", dim(x[[1]])[1], ", ", 32 | dim(x[[1]])[2], ", ", dim(x[[1]])[3], "\n", sep="")) 33 | } 34 | if (!is.null(dimnames(x[[1]])[[1]])) 35 | { 36 | cat(" Term labels\n") 37 | nam <- dimnames(x[[1]])[[1]] 38 | for (i in 1:length(nam)) 39 | { 40 | cat(paste(" (", i, ") ", nam[i], "\n", sep="")) 41 | } 42 | } 43 | if (!is.null(dimnames(x[[1]])[[2]])) 44 | { 45 | cat(" Variable names\n") 46 | nam <- dimnames(x[[1]])[[2]] 47 | for (i in 1:length(nam)) 48 | { 49 | cat(paste(" (", i, ") ", nam[i], "\n", sep="")) 50 | } 51 | } 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /R/nri_subset.R: -------------------------------------------------------------------------------- 1 | setMethod("subset", signature(x = "Nri"), 2 | definition = function(x, subset, ...) 3 | { 4 | subset <- substitute(subset) 5 | return(.subset.nri(x, subset, ...)) 6 | } 7 | ) 8 | 9 | 10 | .subset.nri <- function(x, e, fuzzy = FALSE, ...) 11 | { 12 | target <- data.frame(id.nri = x@dimnames$Sample) 13 | if (nrow(SI(x)) == nrow(target)) 14 | target <- cbind(target, SI(x)) 15 | 16 | if (!fuzzy) 17 | { 18 | dupl <- duplicated(names(target)) 19 | if (any(dupl)) 20 | { 21 | dupl_col <- c(1:length(dupl))*(-1) 22 | target_rm <- dupl_col[dupl]*(-1) 23 | for (i in target_rm) 24 | dupl_col[names(target)==names(target)[target_rm]] <- dupl_col[names(target)==names(target)[target_rm]] * (-1) 25 | dupl_col <- dupl_col[dupl_col>0] 26 | target_rm <- vector(mode="numeric", length=0) 27 | for (i in 1:(length(dupl_col)-1)) 28 | { 29 | for (k in (i+1):length(dupl_col)) 30 | { 31 | if (names(target)[dupl_col[i]]==names(target)[dupl_col[k]]) 32 | { 33 | if (any(target[,dupl_col[i]]!=target[,dupl_col[k]])) 34 | { 35 | warning("Column names not unique") 36 | } else { 37 | target_rm <- c(target_rm,dupl_col[k]*(-1)) 38 | } 39 | } 40 | } 41 | } 42 | if (length(target_rm)>0) 43 | target <- target[, target_rm] 44 | } 45 | } else { 46 | col_names <- as.character(e[2]) 47 | names(target)[agrep(col_names, names(target), ...)] <- col_names 48 | } 49 | 50 | r <- eval(e, envir = target, enclos = parent.frame()) 51 | 52 | if (!is.logical(r)) 53 | stop("'subset' must evaluate to logical") 54 | r <- r & !is.na(r) 55 | 56 | x@nri <- distMat3D(x@nri[,,r]) 57 | 58 | x@dimnames$Sample <- x@dimnames$Sample[r] 59 | 60 | if (nrow(SI(x)) == nrow(target)) 61 | SI(x) <- SI(x, i = r) 62 | e_str <- gsub("\"", "'", as.character(paste(enquote(e)))[2]) 63 | if (length(e_str) == 1) 64 | { 65 | usagehistory(x) <- paste("Subset of nri-values (", e_str, ")", sep = "") 66 | } else { 67 | usagehistory(x) <- "Subset of nri-values" 68 | } 69 | return(x) 70 | } 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /R/rastermeta.R: -------------------------------------------------------------------------------- 1 | rastermeta <- function(x, dim, ext, crs) 2 | { 3 | if (any(c(missing(dim), 4 | missing(ext), 5 | missing(crs)))) 6 | { 7 | if (missing(x)) 8 | stop("'x' required if not all other arguments are passed") 9 | 10 | if (!(class(x)[1] %in% c("Raster", 11 | "RasterBrick", 12 | "Raster", 13 | "HyperSpecRaster", 14 | "RasterStack"))) 15 | stop("'x' does not contain all relevant information") 16 | 17 | if (missing(dim)) 18 | { 19 | dim <- c(nrow(x), ncol(x)) 20 | } else { 21 | if (length(dim) != 2) 22 | stop("Invalid number of dimensions") 23 | if (!is.numeric(dim)) 24 | stop("'dim' must be numeric") 25 | } 26 | if (missing(ext)) 27 | { 28 | ext <- extent(x) 29 | } else { 30 | if (class(ext)[1] != "extent") 31 | stop("'ext' must be object of class 'extent'") 32 | } 33 | if (missing(crs)) 34 | { 35 | crs <- crs(x) 36 | } else { 37 | if (class(crs)[1] != "CRS") 38 | stop("'crs' must be object of class 'CRS'") 39 | } 40 | } else { 41 | if (length(dim) != 2) 42 | stop("Invalid number of dimensions") 43 | if (!is.numeric(dim)) 44 | stop("'dim' must be numeric") 45 | if (class(ext)[1] != "extent") 46 | stop("'ext' must be object of class 'extent'") 47 | if (class(crs)[1] != "CRS") 48 | stop("'crs' must be object of class 'CRS'") 49 | } 50 | return(list(dim = dim, 51 | ext = ext, 52 | crs = crs)) 53 | } 54 | 55 | .is.rastermeta <- function(x) 56 | { 57 | if (class(x)[1] == "list") 58 | { 59 | if (length(x) < 3) 60 | return(FALSE) 61 | if (names(x)[1] != "dim") 62 | return(FALSE) 63 | if (names(x)[2] != "ext") 64 | return(FALSE) 65 | if (names(x)[3] != "crs") 66 | return(FALSE) 67 | } else { 68 | if (class(x)[1] %in% c("Speclib", "Specfeat", "Clman")) 69 | return(.is.rastermeta(x@rastermeta)) 70 | return(FALSE) 71 | } 72 | return(TRUE) 73 | } 74 | 75 | 76 | -------------------------------------------------------------------------------- /R/rededge.R: -------------------------------------------------------------------------------- 1 | rededge <- function(x) 2 | { 3 | if (!is.speclib(x)) 4 | stop("x is not of class 'Speclib'") 5 | 6 | if (x@spectra@fromRaster) 7 | return(.blockwise(speclib_obj = "x", pos = 1)) 8 | 9 | #if (!x@continuousdata) 10 | # stop("x must contain continuous spectral data") 11 | 12 | if (wavelength(x)[1] > 600 || wavelength(x)[length(wavelength(x))] < 900) 13 | stop("x does not contain relevant spectral range. Please ensure that x covers 600 to 900 nm") 14 | 15 | n_sgolay <- floor((25/mean(x@fwhm))/2)*2+1 16 | if (n_sgolay < 5) 17 | n_sgolay <- 5 18 | 19 | D1 <- derivative.speclib(x,method="sgolay",m=1, n=n_sgolay) 20 | D2 <- derivative.speclib(D1,method="sgolay",m=1, n=n_sgolay) 21 | 22 | RedEdge_data <- as.data.frame(t(as.matrix(sapply(c(1:nspectra(x)), 23 | FUN = .rededge_apply, spectra(x), D1, D2), ncol = 6))) 24 | row.names(RedEdge_data) <- idSpeclib(x) 25 | names(RedEdge_data) <- c("R0","l0","Rp","lp","Rs","ls") 26 | 27 | # if (round) 28 | # { 29 | # RedEdge_data[,1] <- round(RedEdge_data[,1], 0) 30 | # RedEdge_data[,2] <- round(RedEdge_data[,2], 0) 31 | # RedEdge_data[,3] <- round(RedEdge_data[,3], 0) 32 | # } 33 | 34 | return(RedEdge_data) 35 | } 36 | 37 | .rededge_apply <- function(i, x, D1, D2) 38 | { 39 | i <- i[1] 40 | tmp <- wavelength(D2) >= 660 & wavelength(D2) <= 700 41 | R0 <- min(x[i,tmp],na.rm=TRUE) 42 | l0 <- wavelength(D2)[tmp] 43 | l0 <- l0[which.min(abs(R0 - x[i,tmp]))] 44 | tmp <- wavelength(D2) >= 700 & wavelength(D2) <= 750 45 | tmp2 <- spectra(D1)[i,] 46 | tmp2[!tmp] <- -99999.9 47 | lp <- which.max(tmp2) 48 | Rp <- x[i,lp] 49 | lp <- wavelength(D2)[lp] 50 | 51 | tmp <- wavelength(D2) > lp & wavelength(D2) < 900 52 | tmp2 <- sign(spectra(D2)[i,tmp]) 53 | tmp3 <- tmp2[-c(1,2)]*tmp2[-c(length(tmp2)-1,length(tmp2))] 54 | tmp3 <- c(FALSE,tmp3==-1,FALSE) 55 | tmp4 <- wavelength(D2)[tmp] 56 | tmp3 <- tmp4[tmp3] 57 | ls <- tmp3[1] 58 | if (is.finite(ls)) 59 | { 60 | Rs <- x[i,wavelength(D2)==ls] 61 | } else { 62 | Rs <- NA 63 | } 64 | return(c(R0,l0,Rp,lp,Rs,ls)) 65 | 66 | } -------------------------------------------------------------------------------- /R/speclib_bandnames.R: -------------------------------------------------------------------------------- 1 | bandnames <- function(x) 2 | { 3 | if (is.null(attr(x, "bandnames"))) 4 | { 5 | return(paste("B", wavelength(x), sep = "_")) 6 | } else { 7 | return(attr(x, "bandnames")) 8 | } 9 | } 10 | 11 | 12 | "bandnames<-" <- function(x, value) 13 | { 14 | xx <- x 15 | attr(xx, "bandnames") <- value 16 | x <- xx 17 | } -------------------------------------------------------------------------------- /R/speclib_differenciate.R: -------------------------------------------------------------------------------- 1 | derivative.speclib <- function( 2 | x, 3 | m=1, 4 | method="sgolay", 5 | ... 6 | ) 7 | { 8 | if (!is.speclib(x)) 9 | stop("x must be of class 'Speclib'") 10 | 11 | if (x@spectra@fromRaster) 12 | return(.blockwise(speclib_obj = "x", pos = 1)) 13 | 14 | res <- x 15 | mf <- FALSE 16 | if (method=="finApprox") 17 | { 18 | mf <- TRUE 19 | spectra(res) <- t(apply(spectra(x), 1, FUN = function(single_spectrum, wl, nwl) 20 | { 21 | return(c((single_spectrum[-1] - single_spectrum[-nwl]) / (wl[-1] - wl[-nwl]), 0)) 22 | }, wavelength(res), nbands(res))) 23 | 24 | # spectra <- as.matrix(spectra(res)) 25 | # nwl <- ncol(spectra) 26 | # n <- nrow(spectra) 27 | # bandc <- res$wavelength 28 | # deriv <- spectra*0 29 | # 30 | # storage.mode(nwl) <- "integer" 31 | # storage.mode(n) <- "integer" 32 | # storage.mode(m) <- "integer" 33 | # storage.mode(bandc) <- "double" 34 | # storage.mode(deriv) <- "double" 35 | # storage.mode(spectra) <- "double" 36 | # 37 | # external <- .Fortran("differenciate", 38 | # nwl=nwl, 39 | # n=n, 40 | # m=m, 41 | # y=spectra, 42 | # bandcenter=bandc, 43 | # derivation=deriv, 44 | # PACKAGE="hsdar" 45 | # ) 46 | # external$derivation <- as.data.frame(external$derivation) 47 | # 48 | # spectra(res) <- external$derivation 49 | usagehistory(res) <- paste(m,". derivation using finite approximation",sep="") 50 | } 51 | if (method=="sgolay") 52 | { 53 | mf <- TRUE 54 | spectra(res) <- t(apply(spectra(x), 1, FUN = sgolayfilt, m = m,...)) 55 | usagehistory(res) <- paste(m,". derivation using Savitzky-Golay filter",sep="") 56 | } 57 | if (!mf) stop("Specified method not found") 58 | 59 | 60 | return(res) 61 | } 62 | -------------------------------------------------------------------------------- /R/speclib_dim.R: -------------------------------------------------------------------------------- 1 | setMethod("dim", signature(x = "Speclib"), 2 | definition = function(x) 3 | { 4 | dimX <- c(nrow(x@spectra), ncol(x@spectra)) 5 | return(dimX) 6 | } 7 | ) 8 | 9 | nspectra <- function(x) 10 | { 11 | if (class(x) == "Nri") 12 | return(dim(x)[3]) 13 | return(dim(x)[1]) 14 | } 15 | 16 | 17 | nbands <- function(x) 18 | { 19 | stopifnot(is.speclib(x)) 20 | return(dim(x)[2]) 21 | } 22 | 23 | 24 | is.speclib <- function(x) 25 | any(c(class(x)[1] == "Speclib", 26 | class(x)[1] == "Specfeat")) 27 | -------------------------------------------------------------------------------- /R/speclib_fwhm.R: -------------------------------------------------------------------------------- 1 | setReplaceMethod("fwhm", signature(object = "Speclib", value = "numeric"), 2 | function(object, value) 3 | { 4 | object@fwhm <- value 5 | return(object) 6 | } 7 | ) 8 | 9 | setMethod("fwhm", signature(object = "Speclib"), 10 | function(object) 11 | return(object@fwhm) 12 | ) -------------------------------------------------------------------------------- /R/speclib_get_reflectance.R: -------------------------------------------------------------------------------- 1 | get_reflectance <- function(spectra, wavelength, position, weighted = FALSE, ...) 2 | { 3 | if (class(spectra)[1] == "Speclib") 4 | { 5 | if (missing(position)) 6 | { 7 | return(get_reflectance(spectra = spectra(spectra), 8 | wavelength = wavelength(spectra), 9 | position = wavelength, 10 | weighted = weighted, ...)) 11 | } else { 12 | if (missing(wavelength)) 13 | { 14 | return(get_reflectance(spectra = spectra(spectra), 15 | wavelength = wavelength(spectra), 16 | position = position, 17 | weighted = weighted, ...)) 18 | } else { 19 | stop("Either wavelength or position is not correctly set") 20 | } 21 | } 22 | } 23 | if (wavelength[1]<=position & wavelength[length(wavelength)]>=position) 24 | { 25 | if (weighted) 26 | { 27 | if (any(wavelength==position)) 28 | { 29 | return(get_reflectance(spectra, wavelength, position, weighted = FALSE)) 30 | } else { 31 | temp <- abs(wavelength-position) 32 | ord <- order(temp) 33 | return((spectra[,ord[1]]*1/temp[ord[1]]+spectra[,ord[2]]*1/temp[ord[2]])/ 34 | (1/temp[ord[1]]+1/temp[ord[2]])) 35 | } 36 | } else { 37 | temp <- abs(wavelength-position) 38 | return(spectra[,which(temp==min(temp))[1]]) 39 | } 40 | } else { 41 | return(rep.int(NA,nrow(spectra))) 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /R/speclib_id.R: -------------------------------------------------------------------------------- 1 | idSpeclib <- function(x) 2 | { 3 | if (!is.speclib(x)) 4 | stop("Class of x must be Speclib") 5 | ids <- x@ID 6 | 7 | return(if (any(c(length(x@ID) != nspectra(x), anyDuplicated(ids)))) c(1:nspectra(x)) else ids) 8 | } 9 | 10 | "idSpeclib<-" <- function(x, value) 11 | { 12 | xx <- x 13 | xx@ID <- value 14 | x <- xx 15 | } 16 | -------------------------------------------------------------------------------- /R/speclib_merge.R: -------------------------------------------------------------------------------- 1 | setMethod("merge", signature(x = "Speclib", y = "Speclib"), 2 | function(x, y, ...) 3 | { 4 | if (dim(x)[2] != dim(y)[2]) 5 | stop("Dimensions of Speclibs do not fit") 6 | 7 | wl <- wavelength(x) 8 | if (any(wl!=wavelength(y))) 9 | stop("Wavelengths differ") 10 | 11 | if (nrow(y@SI) == dim(y)[1]) 12 | { 13 | if (nrow(x@SI) == dim(x)[1]) 14 | { 15 | SI(x) <- rbind(SI(x),SI(y)) 16 | } else { 17 | warning("x does not have proper SI definition. SI information will be lost") 18 | } 19 | } else { 20 | warning("y does not have proper SI definition. SI information will be lost") 21 | } 22 | ids <- c(idSpeclib(x), idSpeclib(y)) 23 | spectra(x) <- as.matrix(rbind(spectra(x),spectra(y))) 24 | idSpeclib(x) <- as.character(ids) 25 | 26 | dots <- list(...) 27 | if (length(dots) > 0) 28 | { 29 | oldhist <- usagehistory(x) 30 | for (i in 1:length(dots)) 31 | { 32 | stopifnot(is.speclib(dots[[i]])) 33 | x <- merge(x, dots[[i]]) 34 | } 35 | usagehistory(x) <- NULL 36 | usagehistory(x) <- oldhist 37 | } 38 | uh <- as.character(.get_args(-1)) 39 | usagehistory(x) <- paste0("Speclibs '", paste(uh[-1], collapse = "', '"), "' merged") 40 | return(x) 41 | } 42 | ) -------------------------------------------------------------------------------- /R/speclib_subset.R: -------------------------------------------------------------------------------- 1 | setMethod("subset", signature(x = "Speclib"), 2 | definition = function(x, subset, ...) 3 | { 4 | subset <- substitute(subset) 5 | return(.subset.speclib(x, subset, ...)) 6 | } 7 | ) 8 | 9 | 10 | .subset.speclib <- function(x, e, fuzzy = FALSE, ...) 11 | { 12 | target <- data.frame(id.speclib = idSpeclib(x)) 13 | if (nrow(SI(x)) == nrow(target)) 14 | target <- cbind(target, SI(x)) 15 | 16 | if (!fuzzy) 17 | { 18 | dupl <- duplicated(names(target)) 19 | if (any(dupl)) 20 | { 21 | dupl_col <- c(1:length(dupl))*(-1) 22 | target_rm <- dupl_col[dupl]*(-1) 23 | for (i in target_rm) 24 | dupl_col[names(target)==names(target)[target_rm]] <- dupl_col[names(target)==names(target)[target_rm]] * (-1) 25 | dupl_col <- dupl_col[dupl_col>0] 26 | target_rm <- vector(mode="numeric", length=0) 27 | for (i in 1:(length(dupl_col)-1)) 28 | { 29 | for (k in (i+1):length(dupl_col)) 30 | { 31 | if (names(target)[dupl_col[i]]==names(target)[dupl_col[k]]) 32 | { 33 | if (any(target[,dupl_col[i]]!=target[,dupl_col[k]])) 34 | { 35 | warning("Column names not unique") 36 | } else { 37 | target_rm <- c(target_rm,dupl_col[k]*(-1)) 38 | } 39 | } 40 | } 41 | } 42 | if (length(target_rm)>0) 43 | target <- target[, target_rm] 44 | } 45 | } else { 46 | col_names <- as.character(e[2]) 47 | names(target)[agrep(col_names, names(target), ...)] <- col_names 48 | } 49 | 50 | r <- eval(e, envir = target, enclos = parent.frame()) 51 | 52 | if (!is.logical(r)) 53 | stop("'subset' must evaluate to logical") 54 | r <- r & !is.na(r) 55 | 56 | id_speclib <- as.character(idSpeclib(x))[r] 57 | spectra(x) <- if (sum(r) == 1) matrix(data=spectra(x)[r,], nrow=1) else spectra(x)[r,] 58 | 59 | if (ncol(SI(x)) == 1) 60 | { 61 | if (nrow(SI(x)) == nrow(target)) 62 | { 63 | tmp <- data.frame(tmp = SI(x, i = r)) 64 | names(tmp) <- names(SI(x)) 65 | SI(x) <- tmp 66 | } 67 | } else { 68 | if (nrow(SI(x)) == nrow(target)) 69 | SI(x) <- SI(x, i = r) 70 | } 71 | e_str <- gsub("\"", "'", as.character(paste(enquote(e)))[2]) 72 | if (length(e_str) == 1) 73 | { 74 | usagehistory(x) <- paste("Subset of spectra (", e_str, ")", sep = "") 75 | } else { 76 | usagehistory(x) <- "Subset of spectra" 77 | } 78 | idSpeclib(x) <- id_speclib 79 | return(x) 80 | } 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /R/speclib_usagehistory.R: -------------------------------------------------------------------------------- 1 | usagehistory <- function (x) 2 | return(x@usagehistory) 3 | 4 | "usagehistory<-" <- function(x, value) 5 | { 6 | xx <- x 7 | if (is.null(value)) 8 | { 9 | xx@usagehistory <- character() 10 | } else { 11 | xx@usagehistory <- if (is.null(xx@usagehistory)) value else c(xx@usagehistory, value) 12 | } 13 | x <- xx 14 | } -------------------------------------------------------------------------------- /R/speclib_wavelength.R: -------------------------------------------------------------------------------- 1 | setReplaceMethod("wavelength", signature(object = "Speclib", value = "numeric"), 2 | function(object, value) 3 | { 4 | object@wavelength <- value 5 | return(object) 6 | } 7 | ) 8 | 9 | setMethod("wavelength", signature(object = "Speclib"), 10 | function(object) 11 | return(object@wavelength) 12 | ) 13 | 14 | .ConvWlFwd <- function(wlunit) 15 | { 16 | micro <- "\u00B5m" 17 | if (wlunit == micro) 18 | wlunit <- "mu" 19 | convwl <- switch(wlunit, 20 | "mu" = 1/1e-03, 21 | "nm" = 1, 22 | "m" = 1/1e-09, 23 | "dm" = 1/1e-08, 24 | "cm" = 1/1e-07, 25 | "mm" = 1/1e-06, 26 | NA 27 | ) 28 | if (!is.finite(convwl)) 29 | stop("Could not recognize wavelength unit") 30 | return(convwl) 31 | } 32 | 33 | .ConvWlBwd <- function(wlunit) 34 | { 35 | micro <- "\u00B5m" 36 | if (wlunit == micro) 37 | wlunit <- "mu" 38 | convwl <- switch(wlunit, 39 | "mu" = 1e-03, 40 | "nm" = 1, 41 | "m" = 1e-09, 42 | "dm" = 1e-08, 43 | "cm" = 1e-07, 44 | "mm" = 1e-06, 45 | NA 46 | ) 47 | if (!is.finite(convwl)) 48 | stop("Could not recognize wavelength unit") 49 | return(convwl) 50 | } 51 | 52 | .ConvWlRnd <- function(wlunit) 53 | { 54 | micro <- "\u00B5m" 55 | if (wlunit == micro) 56 | wlunit <- "mu" 57 | convwl <- switch(wlunit, 58 | "mu" = 4, 59 | "nm" = 2, 60 | "m" = 9, 61 | "dm" = 8, 62 | "cm" = 7, 63 | "mm" = 6, 64 | NA 65 | ) 66 | if (!is.finite(convwl)) 67 | stop("Could not recognize wavelength unit") 68 | return(convwl) 69 | } 70 | -------------------------------------------------------------------------------- /R/spectralInterpolation.R: -------------------------------------------------------------------------------- 1 | spectralInterpolation <- function(x, sensor) 2 | { 3 | if (x@spectra@fromRaster) 4 | return(.blockwise(speclib_obj = "x", pos = 1)) 5 | 6 | if (any(toupper(names(sensor))=="FWHM")) 7 | { 8 | fwhm <- sensor[, which(toupper(names(sensor))=="FWHM")] 9 | } else { 10 | fwhm <- if (pmatch("FWHM", toupper(names(sensor)), nomatch = 0)==0) NULL else sensor[, pmatch("FWHM", toupper(names(sensor)))] 11 | } 12 | if (any(toupper(names(sensor))=="CENTER")) 13 | { 14 | centerwl <- sensor[, which(toupper(names(sensor))=="CENTER")] 15 | } else { 16 | centerwl <- if (pmatch("CENTER", toupper(names(sensor)), nomatch = 0)==0) NULL else sensor[, pmatch("CENTER", toupper(names(sensor)))] 17 | } 18 | if (any(c(is.null(fwhm), is.null(centerwl)))) 19 | { 20 | if (any(toupper(names(sensor))=="LB")) 21 | { 22 | lb <- sensor[, which(toupper(names(sensor))=="LB")] 23 | } else { 24 | lb <- if (pmatch("LB", toupper(names(sensor)), nomatch = 0)==0) NULL else sensor[, pmatch("LB", toupper(names(sensor)))] 25 | } 26 | if (any(toupper(names(sensor))=="UB")) 27 | { 28 | ub <- sensor[, which(toupper(names(sensor))=="UB")] 29 | } else { 30 | ub <- if (pmatch("UB", toupper(names(sensor)), nomatch = 0)==0) NULL else sensor[, pmatch("UB", toupper(names(sensor)))] 31 | } 32 | if (any(c(is.null(lb), is.null(ub)))) 33 | { 34 | lb<-sensor[,1] 35 | ub<-sensor[,2] 36 | } 37 | centerwl <- lb + (ub - lb)/2 38 | fwhm <- (centerwl - lb) * 2 39 | } else { 40 | lb <- centerwl - fwhm/2 41 | ub <- centerwl + fwhm/2 42 | } 43 | sensor <- data.frame(lb = lb, ub = ub) 44 | band_means <- rowMeans(as.matrix(sensor)) 45 | 46 | res <- .Fortran("inter", 47 | b1 = as.double(wavelength(x)), 48 | n_b1 = as.integer(nbands(x)), 49 | b2 = as.double(band_means), 50 | n_b2 = as.integer(length(band_means)), 51 | refl_in = as.double(spectra(x)), 52 | refl_out = as.double(matrix(0, ncol = length(band_means), nrow = nspectra(x))), 53 | nspectra = as.integer(nspectra(x)), 54 | PACKAGE="hsdar" 55 | ) 56 | 57 | res <- res$refl_out 58 | 59 | x_new <- x 60 | wavelength(x_new) <- band_means 61 | fwhm(x_new) <- 2* (band_means - sensor$lb) 62 | spectra(x_new) <- matrix(res, ncol = length(band_means), nrow = nspectra(x)) 63 | usagehistory(x_new) <- paste("Interpolated spectra to user defined channels") 64 | return(x_new) 65 | } 66 | -------------------------------------------------------------------------------- /R/spectral_resampling_gaussian.R: -------------------------------------------------------------------------------- 1 | 2 | get.gaussian.response <- function(fwhm) 3 | { 4 | if (is.null(attr(fwhm, "fwhm"))) 5 | { 6 | if (any(toupper(names(fwhm))=="FWHM")) 7 | { 8 | fwhm_vec <- fwhm[, which(toupper(names(fwhm))=="FWHM")] 9 | } else { 10 | fwhm_vec <- if (pmatch("FWHM", toupper(names(fwhm)))==0) NULL else fwhm[, pmatch("FWHM", toupper(names(fwhm)))] 11 | } 12 | if (any(toupper(names(fwhm))=="CENTER")) 13 | { 14 | centerwl <- fwhm[, which(toupper(names(fwhm))=="CENTER")] 15 | } else { 16 | centerwl <- if (pmatch("CENTER", toupper(names(fwhm)))==0) NULL else fwhm[, pmatch("CENTER", toupper(names(fwhm)))] 17 | } 18 | if (any(c(is.null(fwhm_vec), is.null(centerwl)))) 19 | { 20 | lb<-fwhm[,2] 21 | ub<-fwhm[,3] 22 | centerwl <- lb + (ub - lb)/2 23 | fwhm_vec <- (centerwl - lb) * 2 24 | } 25 | fwhm <- data.frame(channel=c(1:length(centerwl)),center=centerwl,fwhm=fwhm_vec) 26 | } else { 27 | if (!attr(fwhm, "fwhm")) 28 | { 29 | lb <- fwhm[,attr(fwhm, "50pass")[1]] 30 | ub <- fwhm[,attr(fwhm, "50pass")[2]] 31 | centerwl <- lb + (ub - lb)/2 32 | fwhm_vec <- (centerwl - lb) * 2 33 | fwhm <- data.frame(No=c(1:length(centerwl)), center=centerwl, fwhm=fwhm_vec) 34 | } 35 | } 36 | 37 | lb <- fwhm[,2]-fwhm[,3]/2 38 | ub <- fwhm[,2]+fwhm[,3]/2 39 | nch <- nrow(fwhm) 40 | responsedim <- c(min(lb)-(ub[which(lb==min(lb))]-lb[which(lb==min(lb))]), 41 | max(ub)+(ub[which(ub==max(ub))]-lb[which(ub==max(ub))]), 42 | 1) 43 | response <- matrix(data = 0, ncol = nch, nrow =responsedim[2]-responsedim[1]+1) 44 | range_wl <- seq.int(responsedim[1],responsedim[2],responsedim[3]) 45 | for (i in 1:ncol(response)) 46 | { 47 | gauss <- dnorm(range_wl, mean = mean(c(lb[i],ub[i])), sd = (ub[i]-lb[i])/2) 48 | gauss <- (gauss-min(gauss))/(max(gauss)-min(gauss)) 49 | response[,i] <- gauss 50 | } 51 | response <- as.data.frame(response) 52 | names(response) <- paste("Band",c(1:nch),sep="_") 53 | attr(response,"minwl") <- responsedim[1] 54 | attr(response,"maxwl") <- responsedim[2] 55 | attr(response,"stepsize") <- responsedim[3] 56 | return(response) 57 | } -------------------------------------------------------------------------------- /R/sr.R: -------------------------------------------------------------------------------- 1 | sr <- function( 2 | x, 3 | b1, 4 | b2, 5 | recursive = FALSE, 6 | bywavelength = TRUE 7 | ) 8 | { 9 | if (!is.speclib(x)) 10 | stop("x must be of class 'Speclib'") 11 | 12 | range.of.wavelength <- x$fwhm 13 | 14 | reflectance <- spectra(x) 15 | wavelength <- wavelength(x) 16 | 17 | 18 | if (recursive) 19 | { 20 | 21 | if (inherits(nrow(reflectance) * (sum(1:length(wavelength))-length(wavelength)), "error")) 22 | { 23 | stop("Number of Samples*(number of wavelengths^2) exceeds maximum 24 | vector size of 2^31-1") 25 | } 26 | 27 | sr_dat <- single(length = nrow(reflectance) * (sum(1:length(wavelength))-length(wavelength))) 28 | result <- .Fortran("recursive_sr", 29 | nwl = as.integer(length(wavelength)), 30 | nspec = as.integer(nrow(reflectance)), 31 | reflectance = as.single(as.matrix(reflectance)), 32 | sr = sr_dat, 33 | sr_length = as.integer(nrow(reflectance) * 34 | (sum(1:length(wavelength))-length(wavelength))), 35 | PACKAGE = "hsdar" 36 | ) 37 | 38 | result <- distMat3D(as.numeric(result$sr), length(wavelength), nrow(reflectance)) 39 | result <- new("Nri", nri = result, fwhm = range.of.wavelength, 40 | wavelength = wavelength, 41 | dimnames = list(Band_1 = paste("B_", wavelength, sep = ""), 42 | Band_2 = paste("B_", wavelength, sep = ""), 43 | Sample = idSpeclib(x)), 44 | SI = x@SI 45 | ) 46 | if (!is.null(attr(x, "caretParameters"))) 47 | attr(result, "caretParameters") <- attr(x, "caretParameters") 48 | result@usagehistory <- c(x@usagehistory, "SR values calculated") 49 | } else { 50 | b1 <- as.vector(unlist(b1)) 51 | b2 <- as.vector(unlist(b2)) 52 | 53 | stopifnot(length(b1) == length(b2)) 54 | 55 | b1 <- b1 * .ConvWlBwd(x@wlunit) 56 | b2 <- b2 * .ConvWlBwd(x@wlunit) 57 | 58 | if (length(b1) > 1) 59 | { 60 | res <- apply(matrix(1:length(b1), ncol = 1), 1, 61 | FUN = function(i, x, b1, b2, bywavelength) 62 | { 63 | index <- sr(x, b1 = b1[i], b2 = b2[i], bywavelength = bywavelength) 64 | return(index) 65 | }, x, b1, b2, bywavelength) 66 | colnames(res) <- paste("B", b1, "B", b2, sep = "_") 67 | rownames(res) <- idSpeclib(x) 68 | return(res) 69 | } 70 | if (bywavelength) 71 | { 72 | posb1 <- which(wavelength==b1) 73 | posb2 <- which(wavelength==b2) 74 | } else { 75 | posb1 <- b1 76 | posb2 <- b2 77 | } 78 | result <- reflectance[,posb1]/reflectance[,posb2] 79 | if (class(result)=="data.frame") 80 | names(result)<-"SR" 81 | } 82 | return(result) 83 | } 84 | 85 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | .onAttach <- function(lib, pkg) { 2 | packageStartupMessage("\n###################################", 3 | "\n This is hsdar ", 4 | utils::packageDescription("hsdar", 5 | field="Version"), 6 | "\n To get citation entry type", 7 | "\n 'citation(\"hsdar\")'", 8 | "\n###################################", 9 | appendLF = TRUE) 10 | .restoreParallel() 11 | } 12 | -------------------------------------------------------------------------------- /build/hsdar.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/build/hsdar.pdf -------------------------------------------------------------------------------- /build/vignette.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/build/vignette.rds -------------------------------------------------------------------------------- /data/Landsat_4_response.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/data/Landsat_4_response.csv.gz -------------------------------------------------------------------------------- /data/Landsat_5_response.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/data/Landsat_5_response.csv.gz -------------------------------------------------------------------------------- /data/Landsat_7_response.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/data/Landsat_7_response.csv.gz -------------------------------------------------------------------------------- /data/Landsat_8_response.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/data/Landsat_8_response.csv.gz -------------------------------------------------------------------------------- /data/Quickbird_response.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/data/Quickbird_response.csv.gz -------------------------------------------------------------------------------- /data/RapidEye_response.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/data/RapidEye_response.csv.gz -------------------------------------------------------------------------------- /data/Sentinel2A_response.csv.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/data/Sentinel2A_response.csv.xz -------------------------------------------------------------------------------- /data/Sentinel2B_response.csv.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/data/Sentinel2B_response.csv.xz -------------------------------------------------------------------------------- /data/WV_2_8_response.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/data/WV_2_8_response.csv.gz -------------------------------------------------------------------------------- /data/cancer_spectra.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/data/cancer_spectra.RData -------------------------------------------------------------------------------- /data/spectral_data.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/data/spectral_data.RData -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | bibentry(bibtype = "Article", 2 | title = "Hyperspectral Data Analysis in {R}: The {hsdar} Package", 3 | author = c(person(given = c("Lukas", "W."), 4 | family = "Lehnert", 5 | email = "lukaslehnert@googlemail.com"), 6 | person(given = "Hanna", 7 | family = "Meyer"), 8 | person(given = c("Wolfgang", "A."), 9 | family = "Obermeier"), 10 | person(given = "Brenner", 11 | family = "Silva"), 12 | person(given = "Bianca", 13 | family = "Regeling"), 14 | person(given = "Boris", 15 | family = "Thies"), 16 | person(given = "J\\\"{o}rg", 17 | family = "Bendix")), 18 | journal = "Journal of Statistical Software", 19 | year = "2019", 20 | volume = "89", 21 | number = "12", 22 | pages = "1--23", 23 | doi = "10.18637/jss.v089.i12", 24 | 25 | header = "To cite hsdar in publications use:" 26 | ) 27 | 28 | -------------------------------------------------------------------------------- /inst/COPYRIGHTS: -------------------------------------------------------------------------------- 1 | Copyrights of files in package "hsdar" 2 | -------------------------------------- 3 | 4 | Various files in this package have different copyrights. 5 | 6 | 1. Spectral response functions 7 | ------------------------------ 8 | 9 | a) RapidEye: 10 | 11 | data/RapidEye_response.csv.gz 12 | 13 | Copyright by RapidEye AG 14 | Kurfürstendamm 22 15 | 10719 Berlin 16 | Germany 17 | 18 | b) WorldView-2 19 | 20 | data/WV_2_8_response.csv.gz 21 | 22 | © DigitalGlobe, Inc. All Rights Reserved 23 | 1601 Dry Creek Drive, Suite 260 24 | Longmont, CO 80503 25 | USA 26 | 27 | c) Quickbird 28 | 29 | data/Quickbird_response.csv.gz 30 | 31 | © DigitalGlobe, Inc. All Rights Reserved 32 | 1601 Dry Creek Drive, Suite 260 33 | Longmont, CO 80503 34 | USA 35 | 36 | 37 | 2. Source code used in the package 38 | ---------------------------------- 39 | 40 | a) The PROSPECT and PROSAIL models were written by 41 | Jean-Baptiste FERET, Stéphane JACQUEMOUD, 42 | Christophe FRANCOIS, Wout VERHOEF and *...*. 43 | 44 | PROSAIL: 45 | scr/dataSpec_P5B_PROSAIL.f90 46 | scr/dladgen.f 47 | scr/LIDF.f90 48 | scr/main_PROSAIL.f90 49 | scr/MODULE_PRO4SAIL.f90 50 | scr/PRO4SAIL.f90 51 | scr/volscatt.f90 52 | 53 | PROSPECT 5B: 54 | scr/dataSpec_P5B_PROSPECT.f90 55 | scr/main_PROSPECT_5B.f90 56 | 57 | Files used in PROSAIL and PROSPECT 5B: 58 | scr/prospect_5B.f90 59 | scr/tav_abs_PROSPECT_5B.f90 60 | 61 | PROSPECT D: 62 | scr/dataSpec_PDB_PROSPECT.f90 63 | scr/main_PROSPECT_D.f90 64 | scr/prospect_DB.f90 65 | scr/tav_abs_PROSPECT_D.f90 66 | 67 | b) The unmixing routine is based on code originally 68 | written by Markus NETELER for Grass GIS Version 5 69 | 70 | scr/unmix.c 71 | 72 | Copyright 1999-2012 (C) by the GRASS Development Team -------------------------------------------------------------------------------- /inst/doc/Hsdar-intro.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/inst/doc/Hsdar-intro.pdf -------------------------------------------------------------------------------- /inst/doc/References.Rnw: -------------------------------------------------------------------------------- 1 | %\VignetteIndexEntry{References of hyperspectral indices} 2 | 3 | \documentclass{article} 4 | \usepackage[ansinew]{inputenc} 5 | 6 | \usepackage{natbib} 7 | % 8 | %opening 9 | \title{References for package ``hsdar''} 10 | \author{Lukas W.~Lehnert} 11 | 12 | \begin{document} 13 | 14 | \maketitle 15 | \nocite{Wu2014d,Galvao2005,Apan2004,Levin2007,Lobell2001,Mathieu1998,Madeira1997} 16 | \nocite{Hunt2013,Mutanga2004b,Tsai1998,Kruse1993,Thenkabail2000,Jacquemoud2009,Jacquemoud1990a,Clark1987,Mutanga2004c,Sohn1997,Bach1995} 17 | \nocite{Merzlyak1999, Garrity2011, Blackburn1998a, Hernandez-Clemente2011,Hernandez-Clemente2012a,Oppelt2004} 18 | \nocite{Penuelas1997,Penuelas1995a,Hunt1989,Guyot1988,Nagler2003,Huete1988a,Vincini2006,Broge2001,Gao1996,Gamon1992} 19 | \nocite{Boochs1990,Carter1994,CHAPPELLE1992,Chen1996,Dash2004,Datt1999,Datt1998,Daughtry2000,ELVIDGE1995,FILELLA1994,Gandia2004,Gitelson1996,Gitelson1997,Gitelson1999,Gitelson1994,Gitelson2003,Gitelson2003,Haboudane2002,Haboudane2002,Huete1997,JORDAN1969,Kim1994,Lichtenthaler1996,Maccioni2001,Maire2004,Maire2008,MCMURTREY1994,Penuelas1995,Penuelas1994,Qi1994,Rondeaux1996,ROUJEAN1995,ROUJEAN1995,Sims2002,Smith1995,TUCKER1979,VOGELMANN1993,Wu2008,Zarco-Tejada2003b,Zarco-Tejada1999,Serrano2002,Zarco-Tejada2013} 20 | \nocite{Datt1999a,Haubrock2008,Ben-Dor2006,Whiting2004,McNairn1993,Escadafal1994,Escadafal1991} 21 | 22 | \bibliography{hsdar}\bibliographystyle{elsarticle-harv} 23 | 24 | 25 | \end{document} 26 | -------------------------------------------------------------------------------- /inst/doc/References.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/inst/doc/References.pdf -------------------------------------------------------------------------------- /man/Boruta.Rd: -------------------------------------------------------------------------------- 1 | \name{Boruta::Boruta} 2 | \docType{methods} 3 | \alias{Boruta-methods} 4 | \alias{Boruta,Speclib-method} 5 | \alias{Boruta,Nri-method} 6 | \alias{Boruta,Specfeat-method} 7 | \alias{get_Boruta} 8 | 9 | \title{Methods for Function \code{Boruta}} 10 | \description{ 11 | Methods for function \code{Boruta} in package \pkg{Boruta}. Please refer to help pages in the \pkg{Boruta}-package for further information. 12 | } 13 | \usage{ 14 | \S4method{Boruta}{Speclib}(x, y, ..., returnData = TRUE, includeTentative = FALSE, 15 | na.rm = FALSE) 16 | 17 | \S4method{Boruta}{Nri}(x, y, ..., returnData = TRUE, includeTentative = FALSE, 18 | na.rm = FALSE) 19 | 20 | \S4method{Boruta}{Specfeat}(x, y, ..., returnData = TRUE, includeTentative = FALSE, 21 | na.rm = FALSE) 22 | 23 | get_Boruta(x) 24 | } 25 | \arguments{ 26 | \item{x}{ 27 | Object of class \code{Speclib}, \code{Nri} or \code{Specfeat}. For \code{get_Boruta}, \code{x} must be the output of \code{Boruta} as \code{Speclib} or \code{Nri}. 28 | } 29 | \item{y}{ 30 | A numeric or factor vector containing the outcome for each sample. If missing, the response variable set by \code{\link{setResponse}} is used. 31 | } 32 | 33 | 34 | \item{returnData}{ 35 | Logical. If TRUE, the updated object of \code{x} is returned, otherwise only the result of \code{\link{Boruta}} is returned. 36 | } 37 | \item{includeTentative}{ 38 | Logical. If TRUE, the tentative variables are kept and returned in the \code{Speclib}-object.} 39 | \item{na.rm}{ 40 | Logical. If TRUE, all variables are excluded which contain at least one non-finite value.} 41 | \item{...}{ 42 | Further arguments passed to \code{\link{Boruta}}. 43 | } 44 | } 45 | 46 | \value{ 47 | If \code{returnData == TRUE}, an object of class \code{Speclib} or \code{Nri}, otherwise an object of class \code{Boruta}. Note that if \code{x} is an object of class \code{Specfeat}, the function returns an object of class \code{Speclib} containing the relevant transformed band values. 48 | } 49 | 50 | \author{ 51 | Lukas Lehnert 52 | } 53 | 54 | \seealso{ 55 | \code{\link{rfe}}, \code{\link{gafs}} 56 | } 57 | \examples{ 58 | \dontrun{ 59 | data(spectral_data) 60 | 61 | ## Set response variable (Chlorophyll content) 62 | spectral_data <- setResponse(spectral_data, "chlorophyll") 63 | 64 | ## Set additional predictor variables from the SI 65 | spectral_data <- setPredictor(spectral_data, "season") 66 | 67 | ## Run Boruta 68 | ## Note that this may take some time! 69 | bor_res <- Boruta(spectral_data) 70 | 71 | get_Boruta(bor_res) 72 | plot(get_Boruta(bor_res)) 73 | } 74 | } 75 | \keyword{methods} 76 | -------------------------------------------------------------------------------- /man/Clman-class.Rd: -------------------------------------------------------------------------------- 1 | \name{Clman-class} 2 | 3 | \docType{class} 4 | \alias{Clman} 5 | \alias{Clman-class} 6 | 7 | \title{ 8 | * Clman class 9 | } 10 | \description{ 11 | Class to store and handle manual continuum lines. 12 | } 13 | 14 | 15 | \details{ 16 | The class is only required if a continuum line is manually adopted or entirely manually created. This is useful if the automatic approaches are not able to identify absorption features because, for instance, the spectrum has two pronounced maxima within the absortion feature of interest. 17 | 18 | \code{Clman} is defined as \code{\linkS4class{Speclib}} extended by the following two slots: 19 | \itemize{ 20 | \item{cp:}{ Matrix containing the fix points (continuum points) of each spectrum.} 21 | \item{hull:}{ Matrix containing the hull of each spectrum.} 22 | } 23 | 24 | Normally, it is not necessary to manually change the values in any of the slots above. Use the functions \code{\link{addcp}} and \code{\link{deletecp}} to change the hulls manually. Functionality for conversion back to a \code{\linkS4class{Speclib}} with the final hull and the transformed spectra provides function \code{\link{updatecl}}. 25 | } 26 | \note{ 27 | See figure in \code{\link{hsdar-package}} for an overview of classes in hsdar. 28 | } 29 | \author{ 30 | Lukas Lehnert and Hanna Meyer 31 | } 32 | 33 | 34 | \seealso{ 35 | \code{\link{transformSpeclib}}, \code{\link[=plot.Speclib]{plot}}, \code{\linkS4class{Speclib}}, \code{\link{addcp}}, \code{\link{deletecp}}, \code{\link{updatecl}} 36 | } 37 | 38 | \keyword{classes} 39 | 40 | -------------------------------------------------------------------------------- /man/Clman-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{clman} 2 | \docType{methods} 3 | \alias{initialize,Clman-method} 4 | \alias{spectra,Clman-method} 5 | \alias{spectra<-,Clman,data.frame-method} 6 | \alias{spectra<-,Clman,matrix-method} 7 | \alias{spectra<-,Clman,numeric-method} 8 | \alias{plot,Clman-method} 9 | \alias{plot,Clman,ANY-method} 10 | \title{ 11 | Methods to create, manipulate and query objects of class 'Clman'. 12 | } 13 | \description{ 14 | Methods to create, manipulate and query objects of class 'Clman'. The class 'Clman' is used to store manually defined continuum lines and the associated spectra. 15 | } 16 | \usage{ 17 | ## Creation of objects 18 | \S4method{initialize}{Clman}(.Object, ...) 19 | 20 | \S4method{spectra}{Clman}(object, ...) 21 | 22 | \S4method{spectra}{Clman,data.frame}(object) <- value 23 | 24 | \S4method{spectra}{Clman,matrix}(object) <- value 25 | 26 | \S4method{spectra}{Clman,numeric}(object) <- value 27 | 28 | \S4method{plot}{Clman}(x, ispec, subset = NULL, numeratepoints = TRUE, 29 | hull.style = NULL, points.style = list(), ...) 30 | 31 | } 32 | 33 | \arguments{ 34 | \item{.Object,object}{ 35 | Matrix, numeric or array in cases of creation of 'Clman' objects otherwise object of class 'Clman'. 36 | } 37 | \item{value}{ 38 | Object of class numeric, matrix or array which is used for replacement of the values in x. 39 | } 40 | \item{...}{ 41 | Arguments passed to \code{\link{speclib}} or \code{plot.default}. 42 | } 43 | \item{x}{ 44 | Object of class \code{clman}. 45 | } 46 | \item{ispec}{ 47 | Name or index of spectrum to be plotted. 48 | } 49 | \item{subset}{ 50 | Lower and upper spectral limits used for plot. 51 | } 52 | \item{numeratepoints}{ 53 | Flag if points should be numerated in plot. 54 | } 55 | \item{hull.style}{ 56 | List of arguments passed to \code{\link{lines}} to construct the continuum line. 57 | } 58 | \item{points.style}{List of arguments passed to \code{\link{points}} to construct the continuum points. May be \code{NULL} to suppress plotting of fix points.} 59 | } 60 | 61 | \value{ 62 | For \code{spectra<-}, the updated object. Otherwise a matrix returning the spectra in the Clman object. 63 | } 64 | \note{ 65 | The functions to create objects of class \code{Clman} are mainly internally needed by \code{\link{transformSpeclib}}. 66 | } 67 | \author{ 68 | Lukas Lehnert 69 | } 70 | \examples{ 71 | ## Model spectra using PROSAIL 72 | parameter <- data.frame(N = rep.int(c(1, 1.5),2), LAI = c(1,1,3,3)) 73 | spec <- PROSAIL(parameterList=parameter) 74 | 75 | ## Transform spectra 76 | spec_clman <- transformSpeclib(spec, method = "sh", out = "raw") 77 | 78 | ## Return first spectrum 79 | spectra(spec_clman)[1,] 80 | 81 | ## Plot clman 82 | plot(spec_clman, ispec = 1, subset = c(400, 1000)) 83 | } 84 | 85 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 86 | 87 | \seealso{ 88 | \code{\link{dist.speclib}}, \code{\link{Clman}}, \code{\link{transformSpeclib}}, \code{\link[=plot.Speclib]{plot}} 89 | } 90 | 91 | \keyword{aplot} 92 | 93 | -------------------------------------------------------------------------------- /man/DistMat3D-class.Rd: -------------------------------------------------------------------------------- 1 | \name{DistMat3D-class} 2 | \docType{class} 3 | \alias{DistMat3D-class} 4 | 5 | \title{ 6 | * DistMat3D class 7 | } 8 | \description{ 9 | Class to store effectively (large) distance matrices (up to 3D), which can be interpreted as a stack of traditional 2-D distance matrices. Therefore, the first two dimensions are of equal length and usually describe the wavelength in \pkg{hsdar}. This third dimension is normally the number of samples or pixels. In \pkg{hsdar}, objects of class \code{DistMat3D} are used e.g., to store \code{\link{nri}}-values. In this case, the first and second dimensions store the information which band #1 is substraced by which band #2, respectively. The third dimension is the sample. Since it usually does not matter if band #1 is substracted from band #2 or vice versa, the \code{\link{nri}}-matrix would contain the same absolute values on both triangles (as 2-D distance matrices would do). Therefore, \pkg{hsdar} defines and uses the class \code{DistMat3D} in which only one triangle is stored and memory demand is considerably reduced. 10 | } 11 | \details{ 12 | S4-class with 3 slots: 13 | \itemize{ 14 | \item{values: }{Numerical vector containing distance values} 15 | \item{ncol: }{Number of columns in the 3D-matrix. Number of columns equals always the number of rows} 16 | \item{nlyr: }{Number of layers in the 3D-matrix} 17 | } 18 | The data in the values slot is organized as follows: The first value is the distance at band #1 and band #2 for sample number #1, the second one is for band #1 and band #3 (sample #1) and so forth. Methods to create objects of class \code{DistMat3D} for matrix and array objects exist. Additionally, methods to apply functions to the values exist. 19 | } 20 | 21 | \note{ 22 | See figure in \code{\link{hsdar-package}} for an overview of classes in \pkg{hsdar}. 23 | } 24 | 25 | \author{ 26 | Lukas Lehnert 27 | } 28 | 29 | 30 | \seealso{ 31 | \code{\link{distMat3D}}, \code{\link{apply.DistMat3D}} 32 | } 33 | \keyword{classes} 34 | -------------------------------------------------------------------------------- /man/HyperSpecRaster-class.Rd: -------------------------------------------------------------------------------- 1 | \name{HyperSpecRaster-class} 2 | 3 | \docType{class} 4 | 5 | \alias{HyperSpecRaster-class} 6 | \alias{show,HyperSpecRaster-method} 7 | 8 | \title{ HyperSpecRaster* class (deprecated)} 9 | \description{ 10 | This is a deprecated class. Use \code{\linkS4class{Speclib}}-class instead. 11 | } 12 | \author{ 13 | Lukas Lehnert 14 | } 15 | \details{ 16 | Extension of *RasterBrick-class with three additional slots: 17 | \describe{ 18 | \item{\code{wavelength}:}{ A numeric vector giving the center wavelength for each band.} 19 | \item{\code{fwhm} (optional):}{ A numeric vector giving the full-width-half-max values for each band.} 20 | \item{\code{SI} (optional):}{ A \code{data.frame} containing additional information for each pixel.} 21 | } 22 | The information in the three slots are used for the convertion to \code{\linkS4class{Speclib}}. 23 | } 24 | 25 | \seealso{ \code{\link[raster]{brick}}, \code{\linkS4class{Speclib}}} 26 | 27 | \keyword{spatial} 28 | \keyword{classes} 29 | -------------------------------------------------------------------------------- /man/Nri-class.Rd: -------------------------------------------------------------------------------- 1 | \name{Nri-class} 2 | \docType{class} 3 | \alias{Nri-class} 4 | 5 | \title{ 6 | * Nri class 7 | } 8 | \description{ 9 | Class to handle datasets containing normalized ratio indices of spectra. 10 | } 11 | \details{ 12 | Object with slots: 13 | \itemize{ 14 | \item{nri: }{Object of class \code{\linkS4class{DistMat3D}} containing nri values.} 15 | \item{fwhm: }{Vector or single numerical value giving the full-width-half-max value(s) for each band.} 16 | \item{wavelength: }{Vector with wavelength information.} 17 | \item{dimnames: }{Character vector containing band names used to calculate nri-values.} 18 | \item{multivariate: }{List defining the kind of test/model applied to the data and the model data. Only used after object has passed e.g. \code{\link[=glm.nri]{(g)lm.nri}}.} 19 | \item{SI: }{Data.frame containing additional data} 20 | \item{usagehistory: }{Vector giving information on history of usage of the object.} 21 | } 22 | } 23 | \note{ 24 | See figure in \code{\link{hsdar-package}} for an overview of classes in hsdar. 25 | } 26 | 27 | \author{ 28 | Lukas Lehnert 29 | } 30 | 31 | 32 | \seealso{ 33 | \code{\linkS4class{Speclib}} 34 | } 35 | \keyword{classes} 36 | -------------------------------------------------------------------------------- /man/Specfeat-class.Rd: -------------------------------------------------------------------------------- 1 | \name{Specfeat-class} 2 | \docType{class} 3 | \alias{Specfeat-class} 4 | 5 | \title{ 6 | * Specfeat class 7 | } 8 | \description{ 9 | Class to handle spectral feature data. Spectral features are absorption (transmission or reflection) bands defined e.g. by continuum removal (see \code{\link{transformSpeclib}}). 10 | } 11 | \details{ 12 | Class extends \code{Speclib}-class and adds two additional slots: 13 | \itemize{ 14 | \item{features: }{List containing the spectra according to the features.} 15 | \item{featureLimits: }{List containing limits of features defined by \code{\link{specfeat}}.} 16 | } 17 | } 18 | \note{ 19 | See figure in \code{\link{hsdar-package}} for an overview of classes in \pkg{hsdar}. 20 | } 21 | 22 | \author{ 23 | Lukas Lehnert 24 | } 25 | 26 | 27 | \seealso{ 28 | \code{\linkS4class{Speclib}}, \code{\link{specfeat}} 29 | } 30 | \keyword{classes} 31 | -------------------------------------------------------------------------------- /man/USGS.Rd: -------------------------------------------------------------------------------- 1 | \name{import_USGS} 2 | \alias{USGS_get_available_files} 3 | \alias{USGS_retrieve_files} 4 | 5 | \title{ 6 | import USGS spectra 7 | } 8 | \description{ 9 | Import and download spectral data from USGS spectral library 10 | } 11 | \usage{ 12 | USGS_get_available_files(url = NULL) 13 | 14 | USGS_retrieve_files(avl = USGS_get_available_files(), 15 | pattern = NULL, retrieve = TRUE, 16 | loadAsSpeclib = TRUE, tol = 0.1) 17 | } 18 | %- maybe also 'usage' for other objects documented here. 19 | \arguments{ 20 | \item{url}{ 21 | Character passing the url of the data. If NULL, the following URL is used: 22 | 'ftp://ftpext.cr.usgs.gov/pub/cr/co/denver/speclab/pub/spectral.library/splib06.library/ASCII/' 23 | } 24 | \item{avl}{ 25 | List of available files. Typically the result of \code{USGS_get_available_files}. 26 | } 27 | \item{pattern}{ 28 | Search pattern to define a subset of all available spectra. 29 | } 30 | \item{retrieve}{ 31 | Logical. Should the data be downloaded? 32 | } 33 | \item{loadAsSpeclib}{ 34 | Logical. If TRUE, an object of class "Speclib" is retured 35 | } 36 | \item{tol}{ 37 | Discrepancy of the wavelength values between different spectra. 38 | } 39 | } 40 | 41 | \author{ 42 | Lukas Lehnert 43 | } 44 | 45 | \examples{ 46 | \dontrun{ 47 | ## Retrieve all available spectra 48 | avl <- USGS_get_available_files() 49 | 50 | ## Download all spectra matching "grass-fescue" 51 | grass_spectra <- USGS_retrieve_files(avl = avl, pattern = "grass-fescue") 52 | 53 | plot(grass_spectra) 54 | } 55 | } 56 | % Add one or more standard keywords, see file 'KEYWORDS' in the 57 | % R documentation directory. 58 | \keyword{multivariate} 59 | -------------------------------------------------------------------------------- /man/addcp.Rd: -------------------------------------------------------------------------------- 1 | \name{addcp} 2 | \alias{addcp} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Manually add fix point to continuum line 6 | } 7 | \description{ 8 | This function is used to add an additional fix point to a manually created hull of a single spectrum. This fix point is then used to re-construct a continuum line. 9 | } 10 | \usage{ 11 | addcp(x, ispec, cpadd) 12 | } 13 | %- maybe also 'usage' for other objects documented here. 14 | \arguments{ 15 | \item{x}{ 16 | Object of class \code{Clman}. 17 | } 18 | \item{ispec}{ 19 | ID or index of spectrum to be modified. 20 | } 21 | \item{cpadd}{ 22 | Single value or vector of wavelength containing new fix point(s). 23 | } 24 | } 25 | \details{ 26 | In some cases, it might be desirable to manually adapt automatically 27 | constructed segmended hulls (\code{\link{transformSpeclib}}). For example 28 | local maxima could be removed because they are very small and maybe afflicted with uncertainties which might legitimate it to manipulate the continuum line. Therefore, hsdar provides functions to remove and add "continuum points" from or to a continuum line. Manually adapted continuum lines can then be used to update band depth or ratio transformation. Handle these functions with care to avoid continuum lines too much build by subjective decisions. In the typical workflow, spectra are first transformed 29 | (\code{\link{transformSpeclib}}). Continuum points can then be retrieved (\code{\link{getcp}}) and manually adapted by adding \code{\link{addcp}} and deleting (\code{\link{deletecp}}) of points. Use \code{\link{checkhull}} to check for errors. If all uncertainties 30 | are removed, re-calculate the hull (\code{\link{makehull}}) and update the 31 | transformed spectrum (\code{\link{updatecl}}). 32 | } 33 | 34 | \author{ 35 | Lukas Lehnert and Hanna Meyer 36 | } 37 | \value{ 38 | Object of class \code{Clman} containing the updated version of x. 39 | } 40 | \seealso{ 41 | \code{\link{transformSpeclib}}, \code{\link{deletecp}}, \code{\link{getcp}}, 42 | \code{\link{checkhull}}, \code{\link{makehull}}, \code{\link{updatecl}}, 43 | 44 | \code{\link{idSpeclib}} 45 | } 46 | 47 | \examples{ 48 | ## Model spectra using PROSAIL 49 | parameter <- data.frame(N = rep.int(c(1, 1.5),2), LAI = c(1,1,3,3)) 50 | spec <- PROSAIL(parameterList=parameter) 51 | 52 | ## Transform spectra 53 | spec_clman <- transformSpeclib(spec, method = "sh", out = "raw") 54 | 55 | ## Plot original line 56 | par(mfrow = c(1,2)) 57 | plot(spec_clman, ispec = 1, xlim = c(2480, 2500), ylim=c(0.022,0.024)) 58 | 59 | ## Add fix point at 4595 nm to continuum line of first spectrum 60 | spec_clman <- addcp(spec_clman, 1, 2495) 61 | 62 | ## Plot new line 63 | plot(spec_clman, ispec = 1, xlim = c(2480, 2500), ylim=c(0.022,0.024)) 64 | 65 | ## Check new hull 66 | hull <- checkhull(spec_clman, 1) 67 | hull$error 68 | } 69 | \keyword{ utilities } 70 | -------------------------------------------------------------------------------- /man/applySpeclib.Rd: -------------------------------------------------------------------------------- 1 | \name{apply.Speclib} 2 | \alias{apply.Speclib} 3 | \alias{apply,Speclib-method} 4 | 5 | \title{ 6 | Apply function for class Speclib 7 | } 8 | \description{ 9 | Apply function over all spectra or a subset of spectra in a \code{Speclib}. 10 | } 11 | 12 | \usage{ 13 | \S4method{apply}{Speclib}(X, FUN, bySI = NULL, ..., simplify = TRUE) 14 | } 15 | 16 | %- maybe also 'usage' for other objects documented here. 17 | \arguments{ 18 | \item{X}{ 19 | Object of class \code{Speclib} 20 | } 21 | \item{FUN}{ 22 | Function to be applied. Matched with \code{\link{match.fun}}. 23 | } 24 | \item{bySI}{ 25 | Character string giving the name of the column in the SI to be used as subsets to apply function FUN on. 26 | } 27 | \item{...}{ 28 | Further arguments passed to FUN. 29 | } 30 | \item{simplify}{ 31 | Currently ignored. 32 | } 33 | } 34 | 35 | \value{ 36 | Object of class \code{Speclib}. 37 | } 38 | 39 | \author{ 40 | Lukas Lehnert 41 | } 42 | 43 | \seealso{ 44 | \code{\link{apply}}, \code{\link{match.fun}}, \code{\linkS4class{Speclib}} 45 | } 46 | \examples{ 47 | data(spectral_data) 48 | 49 | mean_spectrum <- apply(spectral_data, FUN = mean) 50 | plot(mean_spectrum) 51 | 52 | ## Same as above but seperately for both seasons 53 | mean_spectra <- apply(spectral_data, FUN = mean, bySI = "season") 54 | plot(mean_spectra[1, ], ylim = c(0,50)) 55 | plot(mean_spectra[2, ], new = FALSE) 56 | SI(mean_spectra) 57 | 58 | } 59 | % Add one or more standard keywords, see file 'KEYWORDS' in the 60 | % R documentation directory. 61 | \keyword{utilities} 62 | 63 | -------------------------------------------------------------------------------- /man/bandnames.Rd: -------------------------------------------------------------------------------- 1 | \name{bandnames} 2 | \alias{bandnames} 3 | \alias{bandnames<-} 4 | %- Also NEED an '\alias' for EACH other topic documented here. 5 | \title{ 6 | Handling names of bands 7 | } 8 | \description{ 9 | Returning and setting names of bands in \code{Speclib} 10 | } 11 | \usage{ 12 | bandnames(x) 13 | bandnames(x) <- value 14 | } 15 | %- maybe also 'usage' for other objects documented here. 16 | \arguments{ 17 | \item{x}{ 18 | Object of class \code{Speclib}. 19 | } 20 | \item{value}{ 21 | Character vector of the same length as \code{nbands(x)}, or NULL. 22 | } 23 | } 24 | 25 | \value{ 26 | For \code{bandnames<-}, the updated object. Otherwise a vector giving the name of each band in \code{Speclib} is returned. 27 | } 28 | 29 | \author{ 30 | Lukas Lehnert 31 | } 32 | \note{ 33 | Bandnames are not mandatory in \code{Speclibs}. If not set, the default names are in the form \code{V}+index of bands. 34 | } 35 | 36 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 37 | 38 | \seealso{ 39 | \code{\linkS4class{Speclib}} 40 | } 41 | \examples{ 42 | data(spectral_data) 43 | 44 | ## Return band names 45 | bandnames(spectral_data) 46 | 47 | ## Change band names 48 | bandnames(spectral_data) <- paste("Band", wavelength(spectral_data), 49 | sep = "_") 50 | 51 | ## Return new band names 52 | bandnames(spectral_data) 53 | } 54 | % Add one or more standard keywords, see file 'KEYWORDS' in the 55 | % R documentation directory. 56 | \keyword{utilities} 57 | -------------------------------------------------------------------------------- /man/bdri.Rd: -------------------------------------------------------------------------------- 1 | \name{bdri} 2 | \alias{bdri} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Band depth ratio indices 6 | } 7 | \description{ 8 | Calculate band depth ratio indices for objects of class \code{Specfeat}. 9 | } 10 | \usage{ 11 | bdri(x, fnumber, index = "ndbi") 12 | } 13 | %- maybe also 'usage' for other objects documented here. 14 | \arguments{ 15 | \item{x}{ 16 | Object of class \code{Specfeat}. 17 | } 18 | \item{fnumber}{ 19 | Integer. Index of feature to modify. 20 | } 21 | \item{index}{ 22 | Method to be applied. Currently, \code{"bdr"}, \code{"ndbi"} and \code{"bna"} are available. 23 | } 24 | } 25 | \details{ 26 | Method \code{"bdr"} calculates the normalised band depth ratio as 27 | \deqn{bdr=\frac{BD}{Dc},} 28 | with \eqn{BD} is the band depth calculated by \code{\link{transformSpeclib}} 29 | and Dc is the maximum band depth called band centre. 30 | Method \code{"ndbi"} calculates the the normalised band depth index as 31 | \deqn{ndbi= \frac{BD-Dc}{BD+Dc}.} 32 | Method \code{"bna"} calculates the band depth normalised to band area as 33 | \deqn{bna=\frac{BD}{Da},} 34 | where \eqn{Da} is the area of the absorption feature (see 35 | \code{\link{feature_properties}}). For further information see Mutanga and Skidmore (2004). 36 | } 37 | \references{ 38 | Mutanga, O. and Skidmore, A. (2004): Hyperspectral band depth analysis for a better estimation of grass biomass (\var{Cenchrus ciliaris}) measured under controlled laboratory conditions. International Journal of applied Earth Observation and Geoinformation, 5, 87-96 39 | } 40 | \author{ 41 | Lukas Lehnert and Hanna Meyer 42 | } 43 | \value{ 44 | Object of class \code{specfeat} containing the updated version of x. 45 | } 46 | \seealso{ 47 | \code{\link{transformSpeclib}}, \code{\link{specfeat}} 48 | } 49 | 50 | \examples{ 51 | % \dontrun{ 52 | data(spectral_data) 53 | 54 | ## Transform speclib 55 | bd <- transformSpeclib(subset(spectral_data, season == "summer"), 56 | method = "sh", out = "bd") 57 | 58 | ## Isolate the features around 450nm, 700nm, 1200nm and 1500nm and 59 | ## convert to specfeat. 60 | featureSelection <- specfeat(bd, c(450,700,1200,1500)) 61 | 62 | ## Plot features 63 | plot(featureSelection,1:4) 64 | 65 | ## Calculate normalized band depth index for first feature 66 | featureSelection_bdri <- bdri(featureSelection, 1, index = "ndbi") 67 | 68 | ## Plot result 69 | plot(featureSelection_bdri) 70 | % } 71 | } 72 | \keyword{ utilities } 73 | -------------------------------------------------------------------------------- /man/cancer_spectra.Rd: -------------------------------------------------------------------------------- 1 | \name{cancer_spectra} 2 | \alias{cancer_spectra} 3 | \docType{data} 4 | %- Also NEED an '\alias' for EACH other topic documented here. 5 | \title{ 6 | Hyperspectral samples 7 | } 8 | \description{ 9 | Hyperspectral samples from the human larynx 10 | } 11 | \usage{ 12 | data(cancer_spectra) 13 | } 14 | \details{ 15 | This dataset contains hyperspectral data from the human larynx. The data were acquired in a project aiming to test the feasibility to use hyperspectral imaging for the non-invasive detection of cancer of the human larynx (head-and-neck squamous cell carcinoma). In \pkg{hsdar}, a subset of the total dataset is kindly provided by the project. This subset includes hyperspectral images from 25 patients including 10 cases with histopathological diagnosis of cancer. The images were acquired using an endoscope which was coupled with a monochromatic CCD camera. As light source, a special Polychrome V light machine was used. This allowed to change the wavelength of the impinging radiation so that hyperspectral cubes could be acquired by combining several images taken under different illuminations. The images were preprocessed using the methodology proposed by Regeling et al. (2015). The spectra were manually classified into cancerous and non-cancerous tissue by medical experts which is included in the SI of the data. 16 | } 17 | 18 | \format{An object of class \code{Speclib}} 19 | 20 | \author{Bianca Regeling, Lukas Lehnert} 21 | 22 | \references{ 23 | Regeling, B., Laffers, W., Gerstner, A.O.H., Westermann, S., Mueller, N.A., Schmidt, K., Bendix, J., Thies, B. (2015): Development of an Image Pre-processor for Operational Hyperspectral Laryngeal Cancer Detection. Journal of Biophotonics, 1-11. 24 | } 25 | 26 | \keyword{datasets} 27 | 28 | -------------------------------------------------------------------------------- /man/caret_createDataPartition-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{caret::createDataPartition-methods} 2 | \docType{methods} 3 | \alias{createDataPartition-methods} 4 | \alias{createDataPartition,ANY-method} 5 | \alias{createDataPartition,.CaretHyperspectral-method} 6 | \title{Methods for Function \code{createDataPartition}} 7 | \description{ 8 | Methods for function \code{createDataPartition} in package \pkg{caret}. Please refer to help pages in the \pkg{caret}-package for further information. 9 | } 10 | \section{Methods}{ 11 | \describe{ 12 | 13 | \item{\code{signature(y = ".CaretHyperspectral")}}{ 14 | Wrapper method for \code{\link{createDataPartition}}. 15 | \cr 16 | Note that \code{".CaretHyperspectral"} is a class union containing classes 17 | \Sexpr[echo=TRUE,results=rd]{ 18 | paste(hsdar:::.getCaretCompatibleClasses(), collapse = ", ") 19 | }. 20 | } 21 | }} 22 | \keyword{methods} 23 | -------------------------------------------------------------------------------- /man/caret_createFolds-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{caret::createFolds-methods} 2 | \docType{methods} 3 | \alias{createFolds-methods} 4 | \alias{createMultiFolds-methods} 5 | \alias{createFolds,ANY-method} 6 | \alias{createMultiFolds,ANY-method} 7 | \alias{createFolds,.CaretHyperspectral-method} 8 | \alias{createMultiFolds,.CaretHyperspectral-method} 9 | \title{Methods for Function \code{createFolds} and \code{createMultiFolds}} 10 | \description{ 11 | Methods for functions \code{createFolds} and \code{createMultiFolds} in package \pkg{caret} 12 | } 13 | \section{Methods}{ 14 | \describe{ 15 | 16 | \item{\code{signature(y = ".CaretHyperspectral")}}{ 17 | Wrapper methods for \code{\link{createFolds}} and \code{\link{createMultiFolds}}. 18 | \cr 19 | Note that \code{".CaretHyperspectral"} is a class union containing classes 20 | \Sexpr[echo=TRUE,results=rd]{ 21 | paste(hsdar:::.getCaretCompatibleClasses(), collapse = ", ") 22 | }. 23 | } 24 | }} 25 | \keyword{methods} 26 | -------------------------------------------------------------------------------- /man/caret_createResample-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{caret::createResample-methods} 2 | \docType{methods} 3 | \alias{createResample-methods} 4 | \alias{createResample,ANY-method} 5 | \alias{createResample,.CaretHyperspectral-method} 6 | \title{Methods for Function \code{createResample}} 7 | \description{ 8 | Methods for function \code{createResample} in package \pkg{caret} 9 | } 10 | \section{Methods}{ 11 | \describe{ 12 | 13 | \item{\code{signature(y = ".CaretHyperspectral")}}{ 14 | Wrapper method for \code{\link{createResample}}. 15 | \cr 16 | Note that \code{".CaretHyperspectral"} is a class union containing classes 17 | \Sexpr[echo=TRUE,results=rd]{ 18 | paste(hsdar:::.getCaretCompatibleClasses(), collapse = ", ") 19 | }. 20 | } 21 | }} 22 | \keyword{methods} 23 | -------------------------------------------------------------------------------- /man/caret_featurePlot-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{caret::featurePlot-methods} 2 | \docType{methods} 3 | \alias{featurePlot-methods} 4 | \alias{featurePlot,ANY-method} 5 | \alias{featurePlot,.CaretHyperspectral-method} 6 | \title{Methods for Function \code{featurePlot}} 7 | \description{ 8 | Methods for function \code{featurePlot} in package \pkg{caret} 9 | } 10 | \section{Methods}{ 11 | \describe{ 12 | 13 | \item{\code{signature(x = ".CaretHyperspectral")}}{ 14 | Wrapper method for \code{\link{featurePlot}}. 15 | \cr 16 | Note that \code{".CaretHyperspectral"} is a class union containing classes 17 | \Sexpr[echo=TRUE,results=rd]{ 18 | paste(hsdar:::.getCaretCompatibleClasses(), collapse = ", ") 19 | }. 20 | } 21 | }} 22 | \keyword{methods} 23 | -------------------------------------------------------------------------------- /man/caret_gafs.Rd: -------------------------------------------------------------------------------- 1 | \name{caret::gafs} 2 | \docType{methods} 3 | \alias{gafs-methods} 4 | \alias{get_gafs} 5 | \alias{gafs,Speclib-method} 6 | \alias{gafs,Nri-method} 7 | \alias{gafs,Specfeat-method} 8 | 9 | \title{Methods for Function \code{gafs}} 10 | \description{ 11 | Methods for function \code{gafs} in package \pkg{caret}. Please refer to help pages in the \pkg{caret}-package for further information. 12 | } 13 | \usage{ 14 | \S4method{gafs}{Speclib}(x, y, cutoff = 0.95, returnData = TRUE, na.rm = FALSE, ...) 15 | 16 | \S4method{gafs}{Nri}(x, y, cutoff = 0.95, returnData = TRUE, na.rm = FALSE, ...) 17 | 18 | \S4method{gafs}{Specfeat}(x, y, cutoff = 0.95, returnData = TRUE, na.rm = FALSE, ...) 19 | 20 | get_gafs(x) 21 | } 22 | \arguments{ 23 | \item{x}{ 24 | Object of class \code{Speclib}, \code{Nri} or \code{Specfeat}. For \code{get_gafs}, \code{x} must be the output of \code{gafs} as \code{Speclib} or \code{Nri}. 25 | } 26 | \item{y}{ 27 | A numeric or factor vector containing the outcome for each sample. If missing, the response variable set by \code{\link{setResponse}} is used. 28 | } 29 | 30 | \item{cutoff}{ 31 | The cutoff value of the correlation coefficients between response variables. 32 | } 33 | \item{returnData}{ 34 | Logical. If TRUE, the updated object of \code{x} is returned, otherwise only the result of \code{\link{gafs}} is returned. 35 | } 36 | \item{na.rm}{ 37 | Logical. If TRUE, all variables are excluded which contain at least one non-finite value.} 38 | \item{...}{ 39 | Further aruments passed to \code{\link{gafs}}. 40 | } 41 | } 42 | 43 | \value{ 44 | If \code{returnData == TRUE}, an object of class \code{Speclib} or \code{Nri}, otherwise an object of class \code{gafs}. Note that if \code{x} is an object of class \code{Specfeat}, the function returns an object of class \code{Speclib} containing the relevant transformed band values. 45 | } 46 | 47 | \author{ 48 | Lukas Lehnert 49 | } 50 | 51 | \seealso{ 52 | \code{\link{gafs}} 53 | } 54 | \examples{ 55 | \dontrun{ 56 | data(spectral_data) 57 | 58 | ## Set response variable (Chlorophyll content) 59 | spectral_data <- setResponse(spectral_data, "chlorophyll") 60 | 61 | ## Set additional predictor variables from the SI 62 | spectral_data <- setPredictor(spectral_data, "season") 63 | 64 | ## Feature selection using genetic algorithms 65 | ## Note that this may take some time! 66 | gafs_res <- gafs(spectral_data) 67 | 68 | get_gafs(gafs_res) 69 | } 70 | } 71 | \keyword{methods} 72 | -------------------------------------------------------------------------------- /man/caret_preProcess-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{caret::preProcess-methods} 2 | \docType{methods} 3 | \alias{preProcess-methods} 4 | \alias{preProcess,ANY-method} 5 | \alias{preProcess,.CaretHyperspectral-method} 6 | \alias{show,.preProcessHyperspectral-method} 7 | \alias{preProcess-class} 8 | \title{Methods for Function \code{preProcess}} 9 | \description{ 10 | Methods for function \code{preProcess} in package \pkg{caret}. The function is mainly internally required, but can be also used to transform the reflectance values and the SI e.g., by centering, scaling etc. 11 | } 12 | \section{Methods}{ 13 | \describe{ 14 | 15 | \item{\code{signature(x = ".CaretHyperspectral")}}{ 16 | Wrapper method for \code{\link{preProcess}}. 17 | \cr 18 | Note that \code{".CaretHyperspectral"} is a class union containing classes 19 | \Sexpr[echo=TRUE,results=rd]{ 20 | paste(hsdar:::.getCaretCompatibleClasses(), collapse = ", ") 21 | }. 22 | } 23 | }} 24 | \keyword{methods} 25 | -------------------------------------------------------------------------------- /man/caret_rfe.Rd: -------------------------------------------------------------------------------- 1 | \name{caret::rfe} 2 | \docType{methods} 3 | \alias{rfe-methods} 4 | \alias{get_rfe} 5 | \alias{rfe,Speclib-method} 6 | \alias{rfe,Nri-method} 7 | \alias{rfe,Specfeat-method} 8 | 9 | \title{Methods for Function \code{rfe}} 10 | \description{ 11 | Methods for function \code{rfe} in package \pkg{caret}. Please refer to help pages in the \pkg{caret}-package for further information. 12 | } 13 | \usage{ 14 | \S4method{rfe}{Speclib}(x, y, cutoff = 0.95, returnData = TRUE, na.rm = FALSE, ...) 15 | 16 | \S4method{rfe}{Nri}(x, y, cutoff = 0.95, returnData = TRUE, na.rm = FALSE, ...) 17 | 18 | \S4method{rfe}{Specfeat}(x, y, cutoff = 0.95, returnData = TRUE, na.rm = FALSE, ...) 19 | 20 | get_rfe(x) 21 | } 22 | \arguments{ 23 | \item{x}{ 24 | Object of class \code{Speclib}, \code{Nri} or \code{Specfeat}. For \code{get_rfe}, \code{x} must be the output of \code{rfe} as \code{Speclib} or \code{Nri}. 25 | } 26 | \item{y}{ 27 | A numeric or factor vector containing the outcome for each sample. If missing, the response variable set by \code{\link{setResponse}} is used. 28 | } 29 | 30 | \item{cutoff}{ 31 | The cutoff value of the correlation coefficients between response variables. 32 | } 33 | \item{returnData}{ 34 | Logical. If TRUE, the updated object of \code{x} is returned, otherwise only the result of \code{\link{rfe}} is returned. 35 | } 36 | \item{na.rm}{ 37 | Logical. If TRUE, all variables are excluded which contain at least one non-finite value.} 38 | \item{...}{ 39 | Further aruments passed to \code{\link{rfe}}. 40 | } 41 | } 42 | 43 | \value{ 44 | If \code{returnData == TRUE}, an object of class \code{Speclib} or \code{Nri}, otherwise an object of class \code{rfe}. Note that if \code{x} is an object of class \code{Specfeat}, the function returns an object of class \code{Speclib} containing the relevant transformed band values. 45 | } 46 | 47 | \author{ 48 | Lukas Lehnert 49 | } 50 | 51 | \seealso{ 52 | \code{\link{rfe}} 53 | } 54 | \examples{ 55 | \dontrun{ 56 | data(spectral_data) 57 | 58 | ## Set response variable (Chlorophyll content) 59 | spectral_data <- setResponse(spectral_data, "chlorophyll") 60 | 61 | ## Set additional predictor variables from the SI 62 | spectral_data <- setPredictor(spectral_data, "season") 63 | 64 | ## Recursive feature selection 65 | ## Note that this may take some time! 66 | rfe_res <- rfe(spectral_data) 67 | 68 | get_rfe(rfe_res) 69 | 70 | plot(get_rfe(rfe_res)) 71 | } 72 | } 73 | \keyword{methods} 74 | -------------------------------------------------------------------------------- /man/caret_safs.Rd: -------------------------------------------------------------------------------- 1 | \name{caret::safs} 2 | \docType{methods} 3 | \alias{safs-methods} 4 | \alias{get_safs} 5 | \alias{safs,Speclib-method} 6 | \alias{safs,Nri-method} 7 | \alias{safs,Specfeat-method} 8 | 9 | \title{Methods for Function \code{safs}} 10 | \description{ 11 | Methods for function \code{safs} in package \pkg{caret}. Please refer to help pages in the \pkg{caret}-package for further information. 12 | } 13 | \usage{ 14 | \S4method{safs}{Speclib}(x, y, cutoff = 0.95, returnData = TRUE, na.rm = FALSE, ...) 15 | 16 | \S4method{safs}{Nri}(x, y, cutoff = 0.95, returnData = TRUE, na.rm = FALSE, ...) 17 | 18 | \S4method{safs}{Specfeat}(x, y, cutoff = 0.95, returnData = TRUE, na.rm = FALSE, ...) 19 | 20 | get_safs(x) 21 | } 22 | \arguments{ 23 | \item{x}{ 24 | Object of class \code{Speclib}, \code{Nri} or \code{Specfeat}. For \code{get_safs}, \code{x} must be the output of \code{safs} as \code{Speclib} or \code{Nri}. 25 | } 26 | \item{y}{ 27 | A numeric or factor vector containing the outcome for each sample. If missing, the response variable set by \code{\link{setResponse}} is used. 28 | } 29 | 30 | \item{cutoff}{ 31 | The cutoff value of the correlation coefficients between response variables. 32 | } 33 | \item{returnData}{ 34 | Logical. If TRUE, the updated object of \code{x} is returned, otherwise only the result of \code{\link{safs}} is returned. 35 | } 36 | \item{na.rm}{ 37 | Logical. If TRUE, all variables are excluded which contain at least one non-finite value.} 38 | \item{...}{ 39 | Further aruments passed to \code{\link{safs}}. 40 | } 41 | } 42 | 43 | \value{ 44 | If \code{returnData == TRUE}, an object of class \code{Speclib} or \code{Nri}, otherwise an object of class \code{safs}. Note that if \code{x} is an object of class \code{Specfeat}, the function returns an object of class \code{Speclib} containing the relevant transformed band values. 45 | } 46 | 47 | \author{ 48 | Lukas Lehnert 49 | } 50 | 51 | \seealso{ 52 | \code{\link{safs}} 53 | } 54 | \examples{ 55 | \dontrun{ 56 | data(spectral_data) 57 | 58 | ## Set response variable (Chlorophyll content) 59 | spectral_data <- setResponse(spectral_data, "chlorophyll") 60 | 61 | ## Set additional predictor variables from the SI 62 | spectral_data <- setPredictor(spectral_data, "season") 63 | 64 | ## Supervised feature selection using simulated annealing 65 | ## Note that this may take some time! 66 | safs_res <- safs(spectral_data) 67 | 68 | get_safs(safs_res) 69 | 70 | plot(get_safs(safs_res)) 71 | } 72 | } 73 | \keyword{methods} 74 | -------------------------------------------------------------------------------- /man/caret_setPredictor.Rd: -------------------------------------------------------------------------------- 1 | \name{caret::setPredictor} 2 | \docType{methods} 3 | \alias{setPredictor-methods} 4 | \alias{setPredictor} 5 | \alias{setPredictor,.CaretHyperspectral,character-method} 6 | 7 | \title{Set predictor variable(s)} 8 | \description{ 9 | Set predictor variable(s) to be used in model-fitting functions of package \pkg{caret}. This function can be used to define additional predictor variables stored in the SI of a \code{Speclib}- or \code{Nri}-object. If the passed object is of class \code{Nri}, By default, all Nri-indices (if the passed object is of class \code{Nri}) or all bands (if the passed object is of class \code{Speclib}) are used as predictors. 10 | } 11 | \usage{ 12 | \S4method{setPredictor}{.CaretHyperspectral,character}(x, predictor) 13 | } 14 | \arguments{ 15 | \item{x}{ 16 | Object of one of the following classes: 17 | \Sexpr[echo=TRUE,results=rd]{ 18 | paste(hsdar:::.getCaretCompatibleClasses(), collapse = ", ") 19 | }. 20 | } 21 | \item{predictor}{ 22 | Character vector. Name of additional predictor variable(s) (from the SI). 23 | } 24 | } 25 | 26 | \value{ 27 | The updated object. 28 | } 29 | 30 | \author{ 31 | Lukas Lehnert 32 | } 33 | 34 | \seealso{ 35 | \code{\link{showCaretParameters}}, \code{\link{setResponse}} 36 | } 37 | \examples{ 38 | \dontrun{ 39 | data(spectral_data) 40 | 41 | ## Set "season" as additional predictor variable from the SI 42 | spectral_data <- setPredictor(spectral_data, "season") 43 | 44 | ## Show caret related parameters stored in the Speclib 45 | showCaretParameters(spectral_data) 46 | } 47 | } 48 | \keyword{methods} 49 | -------------------------------------------------------------------------------- /man/caret_setResponse.Rd: -------------------------------------------------------------------------------- 1 | \name{caret::setResponse} 2 | \docType{methods} 3 | \alias{setResponse-methods} 4 | \alias{setResponse} 5 | \alias{setResponse,.CaretHyperspectral,character-method} 6 | 7 | \title{Set response variable} 8 | \description{ 9 | Set response variable to be used in model-fitting functions of package \pkg{caret}. The response variable must be set upon any model training using a \pkg{hsdar}-object in \pkg{caret}. 10 | } 11 | \usage{ 12 | \S4method{setResponse}{.CaretHyperspectral,character}(x, response) 13 | } 14 | \arguments{ 15 | \item{x}{ 16 | Object of one of the following classes: 17 | \Sexpr[echo=TRUE,results=rd]{ 18 | paste(hsdar:::.getCaretCompatibleClasses(), collapse = ", ") 19 | }. 20 | } 21 | \item{response}{ 22 | Character. Name of response variable (from the SI). 23 | } 24 | } 25 | 26 | \value{ 27 | The updated object. 28 | } 29 | 30 | \author{ 31 | Lukas Lehnert 32 | } 33 | \seealso{ 34 | \code{\link{showCaretParameters}}, \code{\link{setPredictor}} 35 | } 36 | \examples{ 37 | \dontrun{ 38 | data(spectral_data) 39 | 40 | ## Set response variable (Chlorophyll content) 41 | spectral_data <- setResponse(spectral_data, "chlorophyll") 42 | 43 | ## Show caret related parameters stored in the Speclib 44 | showCaretParameters(spectral_data) 45 | } 46 | } 47 | \keyword{methods} 48 | -------------------------------------------------------------------------------- /man/caret_sfb.Rd: -------------------------------------------------------------------------------- 1 | \name{caret::sbf} 2 | \docType{methods} 3 | \alias{sbf-methods} 4 | \alias{get_sbf} 5 | \alias{sbf,Speclib-method} 6 | \alias{sbf,Nri-method} 7 | \alias{sbf,Specfeat-method} 8 | 9 | \title{Methods for Function \code{sbf}} 10 | \description{ 11 | Methods for function \code{sbf} in package \pkg{caret}. Please refer to help pages in the \pkg{caret}-package for further information. 12 | } 13 | \usage{ 14 | \S4method{sbf}{Speclib}(x, y, cutoff = 0.95, returnData = TRUE, ...) 15 | 16 | \S4method{sbf}{Nri}(x, y, cutoff = 0.95, returnData = TRUE, ...) 17 | 18 | \S4method{sbf}{Specfeat}(x, y, cutoff = 0.95, returnData = TRUE, ...) 19 | 20 | get_sbf(sbf_obj) 21 | } 22 | \arguments{ 23 | \item{x}{ 24 | Object of class \code{Speclib}, \code{Nri} or \code{Specfeat}. 25 | } 26 | \item{y}{ 27 | A numeric or factor vector containing the outcome for each sample. If missing, the response variable set by \code{\link{setResponse}} is used. 28 | } 29 | 30 | \item{cutoff}{ 31 | The cutoff value of the correlation coefficients between response variables. 32 | } 33 | \item{returnData}{ 34 | Logical. If TRUE, the updated object of \code{x} is returned, otherwise only the result of \code{\link{sbf}} is returned. 35 | } 36 | \item{...}{ 37 | Further aruments passed to \code{\link{sbf}}. 38 | } 39 | \item{sbf_obj}{ 40 | Object of class \code{Speclib}, \code{Nri} or \code{Specfeat} as output of \code{sbf}-function. 41 | } 42 | } 43 | 44 | \value{ 45 | If \code{returnData == TRUE}, an object of class \code{Speclib} or \code{Nri}, otherwise an object of class \code{sbf}. Note that if \code{x} is an object of class \code{Specfeat}, the function returns an object of class \code{Speclib} containing the relevant transformed band values. 46 | } 47 | 48 | \author{ 49 | Lukas Lehnert 50 | } 51 | 52 | \seealso{ 53 | \code{\link{sbf}} 54 | } 55 | \examples{ 56 | \dontrun{ 57 | data(spectral_data) 58 | 59 | ## Set response variable (Chlorophyll content) 60 | spectral_data <- setResponse(spectral_data, "chlorophyll") 61 | 62 | ## Set additional predictor variables from the SI 63 | spectral_data <- setPredictor(spectral_data, "season") 64 | 65 | ## Selection by filtering 66 | ## Note that this may take some time! 67 | sbf_res <- sbf(spectral_data) 68 | 69 | get_sbf(sbf_res) 70 | 71 | plot(get_sbf(sbf_res)) 72 | } 73 | } 74 | \keyword{methods} 75 | -------------------------------------------------------------------------------- /man/caret_showCaretParameters.Rd: -------------------------------------------------------------------------------- 1 | \name{caret::showCaretParameters} 2 | \alias{showCaretParameters} 3 | \alias{showCaretParameters,.CaretHyperspectral-method} 4 | \title{Show caret related parameters} 5 | \description{ 6 | Show caret related parameters in objects of classes \Sexpr[echo=TRUE,results=rd]{ 7 | paste(hsdar:::.getCaretCompatibleClasses(), collapse = ", ") 8 | }. Several parameters such as predictor and response variables are internally stored and used for model training and validation in the \pkg{caret}-package. 9 | } 10 | \usage{ 11 | showCaretParameters(x) 12 | } 13 | \arguments{ 14 | \item{x}{ 15 | Object of one of the following classes: 16 | \Sexpr[echo=TRUE,results=rd]{ 17 | paste(hsdar:::.getCaretCompatibleClasses(), collapse = ", ") 18 | }. 19 | } 20 | } 21 | 22 | \author{ 23 | Lukas Lehnert 24 | } 25 | 26 | \seealso{ 27 | \code{\link{sbf}} 28 | } 29 | 30 | -------------------------------------------------------------------------------- /man/caret_train-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{caret::train-methods} 2 | \docType{methods} 3 | \alias{train-methods} 4 | \alias{train,ANY-method} 5 | \alias{train,.CaretHyperspectral-method} 6 | % \alias{train.formula,formula,Speclib-method} 7 | \title{Methods for Function \code{train}} 8 | \description{ 9 | Methods for functions \code{train} and \code{train.formula} in package \pkg{caret} 10 | } 11 | \section{Methods}{ 12 | \describe{ 13 | 14 | \item{\code{signature(x = ".CaretHyperspectral")}}{ 15 | Wrapper method for \code{\link{train}}. 16 | \cr 17 | Note that \code{".CaretHyperspectral"} is a class union containing classes 18 | \Sexpr[echo=TRUE,results=rd]{ 19 | paste(hsdar:::.getCaretCompatibleClasses(), collapse = ", ") 20 | }. 21 | } 22 | \item{\code{signature(form = "formula", data = "Speclib")}}{ 23 | Wrapper method for \code{\link{train.formula}} to be used with objects of 24 | class \code{Speclib}. 25 | } 26 | }} 27 | \keyword{methods} 28 | -------------------------------------------------------------------------------- /man/checkhull.Rd: -------------------------------------------------------------------------------- 1 | \name{checkhull} 2 | \alias{checkhull} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Check continuum line 6 | } 7 | \description{ 8 | Check if continuum line is intersecting the reflectance curve. 9 | } 10 | \usage{ 11 | checkhull(x, ispec) 12 | } 13 | %- maybe also 'usage' for other objects documented here. 14 | \arguments{ 15 | \item{x}{ 16 | Object of class \code{clman}. 17 | } 18 | \item{ispec}{ 19 | ID or index of spectrum to be checked. 20 | } 21 | } 22 | \details{ 23 | In some cases, it might be desirable to manually adapt automatically 24 | constructed segmended hulls (\code{\link{transformSpeclib}}). For example 25 | local maxima could be removed because they are very small and maybe afflicted with uncertainties which might legitimate it to manipulate the continuum line. Therefore, hsdar provides functions to remove and add "continuum points" from or to a continuum line. Manually adapted continuum lines can then be used to update band depth or ratio transformation. Handle these functions with care to avoid continuum lines too much build by subjective decisions. In the typical workflow, spectra are first transformed 26 | (\code{\link{transformSpeclib}}). Continuum points can then be retrieved (\code{\link{getcp}}) and manually adapted by adding \code{\link{addcp}} and deleting (\code{\link{deletecp}}) of points. Use \code{\link{checkhull}} to check for errors. If all uncertainties 27 | are removed, re-calculate the hull (\code{\link{makehull}}) and update the 28 | transformed spectrum (\code{\link{updatecl}}). 29 | } 30 | \author{ 31 | Lukas Lehnert and Hanna Meyer 32 | } 33 | \value{ 34 | Object of class \code{list}. 35 | } 36 | \seealso{ 37 | \code{\link{transformSpeclib}}, \code{\link{addcp}}, \code{\link{deletecp}}, \code{\link{makehull}}, \code{\link{updatecl}} 38 | } 39 | 40 | \examples{ 41 | ## Model spectra using PROSAIL 42 | parameter <- data.frame(N = rep.int(c(1, 1.5),2), LAI = c(1,1,3,3)) 43 | spec <- PROSAIL(parameterList=parameter) 44 | 45 | ## Transform spectra 46 | spec_clman <- transformSpeclib(spec, method = "sh", out = "raw") 47 | 48 | ## Plot original line 49 | par(mfrow = c(1,2)) 50 | plot(spec_clman, ispec = 1, xlim = c(2480, 2500), ylim=c(0.022,0.024)) 51 | 52 | ## Add fix point at 4595 nm to continuum line of first spectrum 53 | spec_clman <- addcp(spec_clman, 1, 2495) 54 | 55 | ## Plot new line 56 | plot(spec_clman, ispec = 1, xlim = c(2480, 2500), ylim=c(0.022,0.024)) 57 | 58 | ## Check new hull 59 | hull <- checkhull(spec_clman, 1) 60 | hull$error 61 | 62 | ## Add fix point at 4596 nm to continuum line of first spectrum 63 | spec_clman <- addcp(spec_clman, 1, 2496) 64 | 65 | ## Check new hull 66 | hull <- checkhull(spec_clman, 1) 67 | hull$error 68 | } 69 | \keyword{ utilities } 70 | -------------------------------------------------------------------------------- /man/cor.test.normalized.ratio.index.Rd: -------------------------------------------------------------------------------- 1 | \name{cor.test} 2 | \alias{cor.test.nri} 3 | \alias{cor.test,Nri-method} 4 | %\alias{print.cortestnri} 5 | %- Also NEED an '\alias' for EACH other topic documented here. 6 | \title{ 7 | Test for association/correlation between nri values and vector of samples 8 | } 9 | \description{ 10 | Test for association between paired samples (with one variable being nri-values), using one of Pearson's product moment correlation coefficient, Kendall's tau or Spearman's rho. 11 | } 12 | \usage{ 13 | \S4method{cor.test}{Nri}(x, y, ...) 14 | 15 | %\method{print}{cortestnri}(x, ...) 16 | } 17 | %- maybe also 'usage' for other objects documented here. 18 | \arguments{ 19 | \item{x}{ 20 | Object of class \code{Nri} or numerical vector 21 | } 22 | \item{y}{ 23 | Object of class \code{Nri} or numerical vector 24 | } 25 | \item{...}{ 26 | Further arguments passed to \code{\link{cor.test}} 27 | } 28 | } 29 | \details{ 30 | NRI-values may be used as x and/or as y variable. If x and y are NRI-values the number of samples in both datasets must be equal. For additional information on correlation tests see details in \code{\link{cor.test}}. 31 | } 32 | \value{ 33 | Object of class \code{\linkS4class{Nri}} 34 | } 35 | 36 | \author{ 37 | Lukas Lehnert 38 | } 39 | 40 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 41 | 42 | \seealso{ 43 | 44 | \code{\link[=plot.Nri]{plot}}, \code{\link{cor.test}}, \code{\link{glm.nri}}, \code{\link{lm.nri}}, \code{\link{getNRI}} 45 | } 46 | \examples{ 47 | data(spectral_data) 48 | 49 | ## Calculate all possible combinations for WorldView-2-8 50 | spec_WV <- spectralResampling(spectral_data, "WorldView2-8", 51 | response_function = FALSE) 52 | nri_WV <- nri(spec_WV, recursive = TRUE) 53 | 54 | cortestnri <- cor.test(nri_WV, SI(spec_WV)$chlorophyll) 55 | 56 | cortestnri 57 | } 58 | 59 | -------------------------------------------------------------------------------- /man/cut.specfeat.Rd: -------------------------------------------------------------------------------- 1 | \name{cut_specfeat} 2 | \alias{cut_specfeat} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Cut absorption features 6 | } 7 | \description{ 8 | Function cuts absorption features to a user-specified range. Since features may differ among spectra, it might be important to cut the features to specific wavelengths ranges. 9 | 10 | } 11 | \usage{ 12 | cut_specfeat(x, ..., fnumber, limits) 13 | } 14 | %- maybe also 'usage' for other objects documented here. 15 | \arguments{ 16 | \item{x}{ 17 | An object of class \code{Specfeat} containing isolated features determined by \code{\link{specfeat}}. 18 | } 19 | \item{fnumber}{ 20 | A vector of the positions of the features in x to be cut. 21 | } 22 | \item{limits}{ 23 | A vector containing the start and end wavelength for each fnumber. 24 | The corresponding feature will be cut to this specified range. 25 | } 26 | \item{...}{ 27 | Further arguments passed to generic functions. Currently ignored. 28 | } 29 | } 30 | 31 | 32 | \details{ 33 | The typical workflow to obtain feature properties is to first calculate the band 34 | depth \code{\link{transformSpeclib}}, then isolate the absorption features 35 | \code{\link{specfeat}}. Optionally, \code{\link{cut_specfeat}} allows to 36 | cut the features at specified wavelengths. Finally use \code{\link{feature_properties}} 37 | to retrieve characteristics of the features. 38 | 39 | 40 | } 41 | \value{ 42 | An object of class \code{\linkS4class{Specfeat}} containing the cut features. 43 | } 44 | 45 | \author{ 46 | Hanna Meyer and Lukas Lehnert 47 | } 48 | 49 | \seealso{ 50 | \code{\link{specfeat}}, \code{\linkS4class{Specfeat}} 51 | } 52 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 53 | \examples{ 54 | data(spectral_data) 55 | 56 | ##Example to cut the features around 450nm and 700nm to a specific range 57 | ## Transform speclib 58 | bd <- transformSpeclib(subset(spectral_data, season == "summer"), 59 | method = "sh", out = "bd") 60 | 61 | ## Convert speclib to specfeat giving center wavelength of features 62 | featureSelection <- specfeat(bd, c(450,700,1200,1500)) 63 | 64 | ## Cut 1st and 2nd feature to [310 nm, 560 nm] and [589 nm, 800 nm] 65 | featuresCut <- cut_specfeat(x = featureSelection, fnumber = c(1,2), 66 | limits = c(c(310, 560), c(589, 800))) 67 | 68 | ## Plot result (1st and 2nd feature) 69 | plot(featuresCut, fnumber = 1:2) 70 | } -------------------------------------------------------------------------------- /man/deletecp.Rd: -------------------------------------------------------------------------------- 1 | \name{deletecp} 2 | \alias{deletecp} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Delete fix point 6 | } 7 | \description{ 8 | Delete fix point from continuum line. 9 | } 10 | \usage{ 11 | deletecp(x, ispec, cpdelete) 12 | } 13 | %- maybe also 'usage' for other objects documented here. 14 | \arguments{ 15 | \item{x}{ 16 | Object of class \code{Clman}. 17 | } 18 | \item{ispec}{ 19 | ID or index of spectrum to be modified. 20 | } 21 | \item{cpdelete}{ 22 | Single value or vector of wavelength containing fix point(s) to be deleted. 23 | } 24 | } 25 | \details{ 26 | In some cases, it might be desirable to manually adapt automatically 27 | constructed segmended hulls (\code{\link{transformSpeclib}}). For example 28 | local maxima could be removed because they are very small and maybe afflicted with uncertainties which might legitimate it to manipulate the continuum line. Therefore, hsdar provides functions to remove and add "continuum points" from or to a continuum line. Manually adapted continuum lines can then be used to update band depth or ratio transformation. Handle these functions with care to avoid continuum lines too much build by subjective decisions. In the typical workflow, spectra are first transformed 29 | (\code{\link{transformSpeclib}}). Continuum points can then be retrieved (\code{\link{getcp}}) and manually adapted by adding \code{\link{addcp}} and deleting (\code{\link{deletecp}}) of points. Use \code{\link{checkhull}} to check for errors. If all uncertainties 30 | are removed, re-calculate the hull (\code{\link{makehull}}) and update the 31 | transformed spectrum (\code{\link{updatecl}}). 32 | } 33 | \author{ 34 | Lukas Lehnert and Hanna Meyer 35 | } 36 | \value{ 37 | Object of class \code{\linkS4class{Clman}} containing the updated version of x. 38 | } 39 | \seealso{ 40 | \code{\link{transformSpeclib}}, \code{\link{addcp}}, \code{\link{getcp}}, \code{\link{checkhull}}, \code{\link{makehull}}, \code{\link{updatecl}} 41 | } 42 | 43 | \examples{ 44 | ## Model spectra using PROSAIL 45 | parameter <- data.frame(N = rep.int(c(1, 1.5),2), LAI = c(1,1,3,3)) 46 | spec <- PROSAIL(parameterList=parameter) 47 | ## Mask parts not necessary for the example 48 | mask(spec) <- c(1600, 2600) 49 | 50 | ## Transform spectra 51 | spec_clman <- transformSpeclib(spec, method = "sh", out = "raw") 52 | 53 | ## Plot original line 54 | par(mfrow = c(1,2)) 55 | plot(spec_clman, ispec = 1, xlim = c(1100, 1300),ylim=c(0.17,0.21)) 56 | 57 | ## Find wavelength of fix point to be deleted 58 | getcp(spec_clman, 1, subset = c(1100, 1300)) 59 | 60 | ## Delete all fix points between 1200 and 1240 nm 61 | spec_clman <- deletecp(spec_clman, 1, c(1200:1240)) 62 | 63 | ## Plot new line 64 | plot(spec_clman, ispec = 1, xlim = c(1100, 1300),ylim=c(0.17,0.21)) 65 | 66 | ## Check new hull 67 | hull <- checkhull(spec_clman, 1) 68 | hull$error 69 | } 70 | \keyword{ utilities } 71 | -------------------------------------------------------------------------------- /man/derivative_speclib.Rd: -------------------------------------------------------------------------------- 1 | \name{derivative.speclib} 2 | \alias{derivative.speclib} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Derivation 6 | } 7 | \description{ 8 | Calculate derivations of spectra in \code{Speclib}. 9 | } 10 | \usage{ 11 | derivative.speclib(x, m = 1, method = "sgolay", ...) 12 | } 13 | %- maybe also 'usage' for other objects documented here. 14 | \arguments{ 15 | \item{x}{ 16 | Object of class \code{Speclib}. 17 | } 18 | \item{m}{ 19 | Return the m-th derivative of the spectra. 20 | } 21 | \item{method}{ 22 | Character string giving the method to be used. Valid options are \code{"finApprox"} or \code{"sgolay"}. 23 | } 24 | \item{...}{ 25 | Further arguments passed to \code{\link{sgolayfilt}}. 26 | } 27 | } 28 | \details{ 29 | Two different methods are available: 30 | \itemize{ 31 | \item{Finite approximation (\code{finApprox}):}{ 32 | \deqn{\frac{dr}{d\lambda}=\frac{r(\lambda_i)-r(\lambda_{i+1})}{\Delta\lambda},} 33 | where \eqn{r_i} is the reflection in band \eqn{i} and \eqn{\Delta\lambda} the spectral difference between adjacent bands.} 34 | \item{Savitzky-Golay derivative computation (\code{sgolay}, default method)%: 35 | 36 | }{ 37 | % \deqn{\frac{dr^q}{d\lambda}=\sum_{i=-m}^{m}P_i^{(q)}r_{j+i},} 38 | } 39 | } 40 | } 41 | \value{ 42 | Object of class \code{\linkS4class{Speclib}}. 43 | } 44 | \references{ 45 | Tsai, F. & Philpot, W. (1998): Derivative analysis of hyperspectral data. Remote Sensing of Environment 66/1. 41-51. 46 | } 47 | \author{ 48 | Lukas Lehnert 49 | } 50 | \seealso{ 51 | \code{\link{sgolayfilt}}, \code{\link{vegindex}}, \code{\link{soilindex}} 52 | } 53 | \examples{ 54 | data(spectral_data) 55 | 56 | ## Calculate 1st derivation 57 | d1 <- derivative.speclib(spectral_data) 58 | 59 | ## Calculate 2nd derivation 60 | d2 <- derivative.speclib(spectral_data, m = 2) 61 | 62 | ## Calculate 3rd derivation 63 | d3 <- derivative.speclib(spectral_data, m = 3) 64 | 65 | par(mfrow=c(2,2)) 66 | plot(spectral_data) 67 | plot(d1) 68 | plot(d2) 69 | plot(d3) 70 | } 71 | % Add one or more standard keywords, see file 'KEYWORDS' in the 72 | % R documentation directory. 73 | \keyword{utilities} 74 | -------------------------------------------------------------------------------- /man/dim_speclib.Rd: -------------------------------------------------------------------------------- 1 | \name{dim.speclib} 2 | \alias{dim.speclib} 3 | \alias{dim,Speclib-method} 4 | \alias{nspectra} 5 | \alias{nbands} 6 | %- Also NEED an '\alias' for EACH other topic documented here. 7 | \title{ 8 | Dimensions of Speclib 9 | } 10 | \description{ 11 | Get dimension(s) of Speclib 12 | } 13 | \usage{ 14 | \S4method{dim}{Speclib}(x) 15 | 16 | nspectra(x) 17 | nbands(x) 18 | } 19 | %- maybe also 'usage' for other objects documented here. 20 | \arguments{ 21 | \item{x}{ 22 | Object of class \code{Speclib}. 23 | } 24 | } 25 | 26 | \value{ 27 | Vector of length = 2 for \code{dim} or single integer value for \code{nspectra} and \code{nbands}. 28 | } 29 | \author{ 30 | Lukas Lehnert 31 | } 32 | 33 | 34 | \seealso{ 35 | \code{\linkS4class{Speclib}} 36 | } 37 | \examples{ 38 | data(spectral_data) 39 | 40 | dim(spectral_data) 41 | } 42 | % Add one or more standard keywords, see file 'KEYWORDS' in the 43 | % R documentation directory. 44 | \keyword{utilities} 45 | -------------------------------------------------------------------------------- /man/figures/classes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/man/figures/classes.pdf -------------------------------------------------------------------------------- /man/figures/classes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/man/figures/classes.png -------------------------------------------------------------------------------- /man/figures/rededge.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/man/figures/rededge.pdf -------------------------------------------------------------------------------- /man/figures/rededge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/man/figures/rededge.png -------------------------------------------------------------------------------- /man/getNRI.Rd: -------------------------------------------------------------------------------- 1 | \name{getNRI} 2 | \alias{getNRI} 3 | \alias{print.getNRI} 4 | %- Also NEED an '\alias' for EACH other topic documented here. 5 | \title{ 6 | Return nri-values 7 | } 8 | \description{ 9 | Return normalized ratio index values at a given wavelength combination. 10 | } 11 | \usage{ 12 | getNRI(nri, wavelength) 13 | } 14 | %- maybe also 'usage' for other objects documented here. 15 | \arguments{ 16 | \item{nri}{ 17 | Object of class 'Nri' 18 | } 19 | \item{wavelength}{ 20 | Wavelength values where nri is returned. See details section. 21 | } 22 | } 23 | \details{ 24 | Wavelength can be passed in three ways. As the result of \code{\link{nri_best_performance}}, as a data frame with two columns or as a vector of length 2. In the first two cases, the result will be a data frame (if data frames contain more than one row) with the nri-values of each pair of wavelengths. In the latter case it will be a vector. 25 | } 26 | \author{ 27 | Lukas Lehnert 28 | } 29 | 30 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 31 | 32 | \seealso{ 33 | \code{\link{nri}}, \code{\linkS4class{Nri}} 34 | } 35 | \examples{ 36 | data(spectral_data) 37 | 38 | ## Calculate all possible combinations for WorldView-2-8 39 | spec_WV <- spectralResampling(spectral_data, "WorldView2-8", 40 | response_function = FALSE) 41 | nri_WV <- nri(spec_WV, recursive = TRUE) 42 | 43 | ## Build glm-models 44 | glmnri <- glm.nri(nri_WV ~ chlorophyll, preddata = spec_WV) 45 | 46 | ## Return best 5 models 47 | BM <- nri_best_performance(glmnri, n = 5, coefficient = "p.value") 48 | 49 | ## Get nri values for the 5 models 50 | nri_BM <- getNRI(nri_WV, BM) 51 | 52 | } 53 | % Add one or more standard keywords, see file 'KEYWORDS' in the 54 | % R documentation directory. 55 | \keyword{multivariate} 56 | -------------------------------------------------------------------------------- /man/get_reflectance.Rd: -------------------------------------------------------------------------------- 1 | \name{get_reflectance} 2 | \alias{get_reflectance} 3 | 4 | 5 | \title{Get reflectance values} 6 | \description{ 7 | Returns weighted or unweighted reflectance values at wavelength position. 8 | } 9 | 10 | \usage{ 11 | get_reflectance(spectra, wavelength, position, weighted = FALSE, ...) 12 | 13 | } 14 | \arguments{ 15 | \item{spectra}{ 16 | Object of class \code{Speclib} or data.frame with reflectance values. 17 | } 18 | \item{wavelength}{ 19 | Vector with wavelength values. May be missing if spectra is object of class \code{Speclib}. 20 | } 21 | \item{position}{ 22 | Numeric value passing the position of reflectance values to be returned in dimensions of the wavelength values. 23 | } 24 | \item{weighted}{ 25 | Logical indicating if reflectance values should be interpolated to fit wavelength position. If \code{FALSE} the reflectance values of nearest neighbour to passed position are returned. 26 | } 27 | \item{...}{ 28 | Arguments to be passed to specific functions. Currently ignored. 29 | } 30 | } 31 | \value{ 32 | A vector with reflectance values for each spectrum is returned. If position falls outside of spectral range of input values, \code{NA} values are returned. 33 | } 34 | \author{ Lukas Lehnert \& Hanna Meyer } 35 | \seealso{ 36 | \code{\link[=spectra.Speclib]{spectra}} 37 | } 38 | \examples{ 39 | data(spectral_data) 40 | 41 | ## Simulate multispectral sensor encompassing two bands 42 | ## to show effect of weighted and unweighted modes 43 | spectral_data_res <- spectralResampling(spectral_data, 44 | sensor = data.frame(lb = c(400, 600), ub = c(500, 700))) 45 | 46 | ## Compare reflectance at 520 nm (in between both bands to 47 | ## show the difference between weighted and unweighted modes) 48 | weighted_reflectance <- get_reflectance(spectral_data_res, 49 | 520, weighted = TRUE) 50 | unweighted_reflectance <- get_reflectance(spectral_data_res, 51 | 520, weighted = FALSE) 52 | 53 | ## Plot result 54 | plot(weighted_reflectance, unweighted_reflectance, 55 | ylab = "Reflectance at 520 nm (unweighted)", 56 | xlab = "Reflectance at 520 nm (weighted)") 57 | } 58 | -------------------------------------------------------------------------------- /man/getcp.Rd: -------------------------------------------------------------------------------- 1 | \name{getcp} 2 | \alias{getcp} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Get fix points 6 | } 7 | \description{ 8 | Get fix points of continuum line within spectral range. 9 | } 10 | \usage{ 11 | getcp(x, ispec, subset = NULL) 12 | } 13 | %- maybe also 'usage' for other objects documented here. 14 | \arguments{ 15 | \item{x}{ 16 | Object of class \code{Clman}. 17 | } 18 | \item{ispec}{ 19 | ID or index of spectrum to be analysed. 20 | } 21 | \item{subset}{ 22 | Vector of \code{length = 2} giving the lower and upper limit of spectral range. 23 | } 24 | } 25 | \author{ 26 | Lukas Lehnert and Hanna Meyer 27 | } 28 | \value{ 29 | Object of class \code{list} containing two elements: 30 | \itemize{ 31 | \item{ptscon:}{ Data frame with wavelength and reflectance of fix points} 32 | \item{ispec:}{ Index of analysed spectrum within passed \code{Clman}-object.} 33 | } 34 | } 35 | \seealso{ 36 | \code{\link{transformSpeclib}}, \code{\link{deletecp}}, \code{\link{addcp}}, \code{\linkS4class{Clman}} 37 | } 38 | 39 | \examples{ 40 | ## Model spectra using PROSAIL 41 | parameter <- data.frame(N = rep.int(c(1, 1.5),2), LAI = c(1,1,3,3)) 42 | spec <- PROSAIL(parameterList=parameter) 43 | 44 | ## Transform spectra 45 | spec_clman <- transformSpeclib(spec, method = "sh", out = "raw") 46 | 47 | ## Fix points 48 | spec_cp <- getcp(spec_clman, 1, c(400, 800)) 49 | spec_cp 50 | } 51 | \keyword{ utilities } 52 | -------------------------------------------------------------------------------- /man/hsdar_parallel.Rd: -------------------------------------------------------------------------------- 1 | \name{hsdar_parallel} 2 | \alias{hsdar_parallel} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | hsdar_parallel 6 | } 7 | \description{ 8 | Get all functions which support parallel execution. Currently, the parallel backend functions in \pkg{doMPI} and \pkg{doMC} are supported. 9 | } 10 | \usage{ 11 | hsdar_parallel() 12 | } 13 | %- maybe also 'usage' for other objects documented here. 14 | \details{ 15 | Parallel execution is performed via the \pkg{foreach}-package. Care is taken that a function will never run in parallel if the calling function is already using multicore processing. 16 | } 17 | 18 | \author{ 19 | Lukas Lehnert 20 | } 21 | \value{ 22 | Vector containing supported function names 23 | } 24 | % \seealso{ 25 | % \code{\link{foreach}} 26 | % } 27 | 28 | \examples{ 29 | \dontrun{ 30 | supported_functions <- hsdar_parallel() 31 | supported_functions 32 | 33 | data(spectral_data) 34 | 35 | ## Example for Windows and other systems where doMPI is available 36 | ## Load library 37 | library(doMPI) 38 | ## Register number of workers 39 | cl <- startMPIcluster(count = 3) 40 | registerDoMPI(cl) 41 | 42 | ## Transform speclib using 3 cores 43 | bd <- transformSpeclib(spectral_data) 44 | 45 | ## Close the cluster (important to get rid of processes) 46 | closeCluster(cl) 47 | 48 | ## Example for Linux and other systems where doMC is available 49 | ## Load library 50 | library(doMC) 51 | ## Register number of workers 52 | registerDoMC(3) 53 | 54 | ## Transform speclib using 3 cores 55 | bd <- transformSpeclib(spectral_data) 56 | } 57 | } 58 | \keyword{ utilities } 59 | -------------------------------------------------------------------------------- /man/hsdardocs.Rd: -------------------------------------------------------------------------------- 1 | \name{hsdardocs} 2 | \alias{hsdardocs} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Load additional documents 6 | } 7 | \description{ 8 | Access help documents and references for different methods. 9 | } 10 | \usage{ 11 | hsdardocs(doc) 12 | } 13 | %- maybe also 'usage' for other objects documented here. 14 | \arguments{ 15 | \item{doc}{ 16 | Name of document to load. Currently, \code{"Hsdar-intro.pdf"}, \code{"References.pdf"} and 17 | \code{"Copyright"} are available 18 | } 19 | 20 | } 21 | \author{ 22 | Lukas Lehnert 23 | } 24 | 25 | 26 | \examples{ 27 | \dontrun{ 28 | ## Open introduction to hsdar (PDF-file) 29 | hsdardocs("Hsdar-intro.pdf") 30 | 31 | ## Open references of hyperspectral vegetation indices (PDF-file) 32 | hsdardocs("References.pdf") 33 | 34 | ## See copyrights of routines and data used in hsdar-package (ascii-file) 35 | hsdardocs("Copyright") 36 | } 37 | } 38 | \keyword{ utilities } 39 | \keyword{ documentation } 40 | -------------------------------------------------------------------------------- /man/id_speclib.Rd: -------------------------------------------------------------------------------- 1 | \name{idSpeclib} 2 | \alias{idSpeclib} 3 | \alias{idSpeclib<-} 4 | %- Also NEED an '\alias' for EACH other topic documented here. 5 | \title{ 6 | Handling IDs of spectra 7 | } 8 | \description{ 9 | Returning and setting ID of spectra in Speclib 10 | } 11 | \usage{ 12 | idSpeclib(x) 13 | idSpeclib(x) <- value 14 | } 15 | %- maybe also 'usage' for other objects documented here. 16 | \arguments{ 17 | \item{x}{ 18 | Object of class \code{Speclib}. 19 | } 20 | \item{value}{ 21 | Character vector of the same length as \code{nspectra(x)}, or NULL. 22 | } 23 | } 24 | 25 | \value{ 26 | For \code{idSpeclib<-}, the updated object. Otherwise a vector giving the ID of each spectrum in Speclib is returned. 27 | } 28 | 29 | \author{ 30 | Lukas Lehnert 31 | } 32 | 33 | 34 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 35 | 36 | \seealso{ 37 | \code{\linkS4class{Speclib}} 38 | } 39 | \examples{ 40 | data(spectral_data) 41 | 42 | idSpeclib(spectral_data) 43 | } 44 | % Add one or more standard keywords, see file 'KEYWORDS' in the 45 | % R documentation directory. 46 | \keyword{utilities} 47 | -------------------------------------------------------------------------------- /man/makehull.Rd: -------------------------------------------------------------------------------- 1 | \name{makehull} 2 | \alias{makehull} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Re-calculate hull 6 | } 7 | \description{ 8 | Re-calculates the hull after it was manually adapted 9 | } 10 | \usage{ 11 | makehull(x, ispec) 12 | } 13 | %- maybe also 'usage' for other objects documented here. 14 | \arguments{ 15 | \item{x}{ 16 | Object of class \code{Clman}. 17 | } 18 | \item{ispec}{ 19 | Name or index of spectrum to be checked. 20 | } 21 | } 22 | \details{ 23 | In some cases, it might be desirable to manually adapt automatically 24 | constructed segmended hulls (\code{\link{transformSpeclib}}). For example 25 | local maxima could be removed because they are very small and maybe afflicted with uncertainties which might legitimate it to manipulate the continuum line. Therefore, hsdar provides functions to remove and add "continuum points" from or to a continuum line. Manually adapted continuum lines can then be used to update band depth or ratio transformation. Handle these functions with care to avoid continuum lines too much build by subjective decisions. In the typical workflow, spectra are first transformed 26 | (\code{\link{transformSpeclib}}). Continuum points can then be retrieved (\code{\link{getcp}}) and manually adapted by adding \code{\link{addcp}} and deleting (\code{\link{deletecp}}) of points. Use \code{\link{checkhull}} to check for errors. If all uncertainties 27 | are removed, re-calculate the hull (\code{\link{makehull}}) and update the 28 | transformed spectrum (\code{\link{updatecl}}). 29 | } 30 | \author{ 31 | Lukas Lehnert and Hanna Meyer 32 | } 33 | \value{ 34 | Object of class \code{list}. 35 | } 36 | \seealso{ 37 | \code{\link{transformSpeclib}}, \code{\link{addcp}}, \code{\link{deletecp}}, \code{\link{makehull}}, \code{\link{updatecl}} 38 | 39 | \code{\linkS4class{Clman}} 40 | } 41 | 42 | \examples{ 43 | ## Model spectra using PROSAIL 44 | parameter <- data.frame(N = rep.int(c(1, 1.5),2), LAI = c(1,1,3,3)) 45 | spec <- PROSAIL(parameterList=parameter) 46 | 47 | ## Transform spectra 48 | spec_clman <- transformSpeclib(spec, method = "sh", out = "raw") 49 | 50 | ## Plot original line 51 | par(mfrow = c(1,2)) 52 | plot(spec_clman, ispec = 1, xlim = c(2480, 2500), ylim=c(0.022,0.024)) 53 | 54 | ## Add fix point at 4595 nm to continuum line of first spectrum 55 | spec_clman <- addcp(spec_clman, 1, 2495) 56 | 57 | ## Plot new line 58 | plot(spec_clman, ispec = 1, xlim = c(2480, 2500), ylim=c(0.022,0.024)) 59 | 60 | ## Check new hull 61 | hull <- checkhull(spec_clman, 1) 62 | hull$error 63 | 64 | ## Add fix point at 4596 nm to continuum line of first spectrum 65 | spec_clman <- addcp(spec_clman, 1, 2496) 66 | 67 | ## Check new hull 68 | hull <- checkhull(spec_clman, 1) 69 | hull$error 70 | 71 | ## Re-calculate hull 72 | hull <- makehull(spec_clman, 1) 73 | 74 | ## Transform spectra using band depth 75 | spec_bd <- transformSpeclib(spec, method = "sh", out = "bd") 76 | 77 | ## Update continuum line of first spectrum 78 | spec_bd <- updatecl(spec_bd, hull) 79 | 80 | ## Plot modified transformed spectrum 81 | plot(spec_bd, FUN = 1) 82 | } 83 | \keyword{ utilities } 84 | -------------------------------------------------------------------------------- /man/mask.Rd: -------------------------------------------------------------------------------- 1 | \name{mask} 2 | \alias{mask} 3 | \alias{mask<-} 4 | \alias{maskSpeclib} 5 | \alias{mask,Speclib-method} 6 | \alias{mask<-,Speclib,data.frame-method} 7 | \alias{mask<-,Speclib,list-method} 8 | \alias{mask<-,Speclib,numeric-method} 9 | \alias{mask<-,Speclib,matrix-method} 10 | \alias{interpolate.mask} 11 | %- Also NEED an '\alias' for EACH other topic documented here. 12 | \title{ 13 | Mask spectra 14 | } 15 | \description{ 16 | Returning and setting mask of spectra in \code{Speclib}. \code{interpolate.mask} linearly interpolates masked parts in spectra. 17 | } 18 | \usage{ 19 | \S4method{mask}{Speclib}(object) 20 | \S4method{mask}{Speclib,data.frame}(object) <- value 21 | \S4method{mask}{Speclib,list}(object) <- value 22 | \S4method{mask}{Speclib,numeric}(object) <- value 23 | 24 | ## Linear interpolation of masked parts 25 | interpolate.mask(object) 26 | } 27 | %- maybe also 'usage' for other objects documented here. 28 | \arguments{ 29 | \item{object}{ 30 | Object of class \code{Speclib}. 31 | } 32 | \item{value}{ 33 | Numeric vector, data frame or list giving the mask boundaries in wavelength units. See details section. 34 | } 35 | } 36 | \details{ 37 | Value may be an object of class vector, data frame or list. Data frames must contain 2 columns with the first column giving the lower (lb) and the second the upper boundary (ub) of the wavelength ranges to be masked. List must have two items consisting of vectors of length = 2. The first entry is used as lower and the second as upper boundary value. Vectors must contain corresponding lower and upper boundary values consecutively. The masked wavelength range(s) as defined by the lower and upper boundaries are excluded from the object of class \code{Speclib}. 38 | 39 | Interpolation of masked parts is mainly intended for internal use. Interpolation is only possible if mask does not exceed spectral range of \code{Speclib}. 40 | } 41 | \value{ 42 | For \code{mask<-}, the updated object. Otherwise a data frame giving the mask boundaries. 43 | 44 | \code{interpolate.mask} returns a new object of class \code{Speclib}. 45 | } 46 | 47 | \author{ 48 | Lukas Lehnert and Hanna Meyer 49 | } 50 | 51 | 52 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 53 | 54 | \seealso{ 55 | \code{\linkS4class{Speclib}} 56 | } 57 | \examples{ 58 | data(spectral_data) 59 | 60 | mask(spectral_data) ## NULL 61 | 62 | 63 | ## Mask from vector 64 | spectral_data_ve <- spectral_data 65 | mask(spectral_data_ve) <- c(1040,1060,1300,1450) 66 | mask(spectral_data_ve) 67 | 68 | 69 | ## Mask from data frame 70 | spectral_data_df <- spectral_data 71 | mask(spectral_data_df) <- data.frame(lb=c(1040,1300),ub=c(1060,1450)) 72 | mask(spectral_data_df) 73 | 74 | 75 | ## Mask from list 76 | spectral_data_li <- spectral_data 77 | mask(spectral_data_li) <- list(lb=c(1040,1300),ub=c(1060,1450)) 78 | mask(spectral_data_li) 79 | 80 | ## Linear interpolation 81 | plot(spectral_data) 82 | plot(interpolate.mask(spectral_data_li), new=FALSE) 83 | } 84 | % Add one or more standard keywords, see file 'KEYWORDS' in the 85 | % R documentation directory. 86 | \keyword{utilities} 87 | -------------------------------------------------------------------------------- /man/meanfilter.Rd: -------------------------------------------------------------------------------- 1 | \name{meanfilter} 2 | \alias{meanfilter} 3 | 4 | %- Also NEED an '\alias' for EACH other topic documented here. 5 | \title{ 6 | Apply mean filter 7 | } 8 | \description{ 9 | Apply mean filter to spectra. Filter size is passed as number of bands averaged at both sides of the respective band value. 10 | } 11 | \usage{ 12 | meanfilter(spectra, p = 5) 13 | } 14 | %- maybe also 'usage' for other objects documented here. 15 | \arguments{ 16 | \item{spectra}{ 17 | Data.frame, matrix or Speclib containing spectra 18 | } 19 | \item{p}{ 20 | Filter size. 21 | } 22 | } 23 | 24 | \value{ 25 | Filtered matrix or Speclib of same dimension as input matrix/Speclib 26 | } 27 | 28 | \author{ 29 | Lukas Lehnert 30 | } 31 | 32 | 33 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 34 | 35 | \seealso{ 36 | \code{\link{noiseFiltering}} 37 | } 38 | \examples{ 39 | data(spectral_data) 40 | 41 | spectra_filtered <- meanfilter(spectral_data, p = 10) 42 | plot(spectra_filtered[1,]) 43 | plot(spectral_data[1,], new = FALSE) 44 | 45 | 46 | } 47 | % Add one or more standard keywords, see file 'KEYWORDS' in the 48 | % R documentation directory. 49 | \keyword{smooth} 50 | -------------------------------------------------------------------------------- /man/merge_speclib.Rd: -------------------------------------------------------------------------------- 1 | \name{merge} 2 | \alias{merge,Speclib,Speclib-method} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Merge speclibs 6 | } 7 | \description{ 8 | Merge two \code{Speclib}s and their SI data 9 | } 10 | \usage{ 11 | \S4method{merge}{Speclib,Speclib}(x, y, ...) 12 | } 13 | %- maybe also 'usage' for other objects documented here. 14 | \arguments{ 15 | \item{x}{ 16 | 1st Object of class \code{Speclib} to be merged. 17 | } 18 | \item{y}{ 19 | 2nd Object of class \code{Speclib} to be merged. 20 | } 21 | \item{...}{ 22 | Further (optional) objects of class \code{Speclib}. 23 | } 24 | } 25 | 26 | \value{ 27 | Object of class \code{Speclib}. 28 | } 29 | \author{ 30 | Lukas Lehnert 31 | } 32 | 33 | \seealso{ 34 | \code{\linkS4class{Speclib}} 35 | } 36 | \examples{ 37 | data(spectral_data) 38 | sp1 <- spectral_data[c(1:10),] 39 | sp2 <- spectral_data[c(11:20),] 40 | 41 | ## Merge two Speclibs 42 | speclib_merged_1 <- merge(sp1, sp2) 43 | nspectra(speclib_merged_1) 44 | 45 | ## Merge multiple Speclibs 46 | sp3 <- spectral_data[c(21:30),] 47 | speclib_merged_2 <- merge(sp1, sp2, sp3) 48 | nspectra(speclib_merged_2) 49 | } 50 | \keyword{utilities} 51 | -------------------------------------------------------------------------------- /man/normalized.ratio.index-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{Nri-methods} 2 | \alias{$,Nri-method} 3 | \alias{as.matrix,Nri-method} 4 | \alias{as.data.frame,Nri-method} 5 | \alias{show,Nri-method} 6 | \alias{print,Nri-method} 7 | \alias{dim,Nri-method} 8 | \alias{wavelength,Nri-method} 9 | \alias{[,Nri,ANY,ANY-method} 10 | \alias{[,Nri,ANY,ANY,ANY-method} 11 | \alias{getFiniteNri} 12 | %\alias{as.matrix.nri} 13 | %- Also NEED an '\alias' for EACH other topic documented here. 14 | \title{ 15 | Methods for * Nri-class 16 | } 17 | \description{ 18 | Methods to handle data in objects of class Nri. 19 | } 20 | \usage{ 21 | \S4method{as.matrix}{Nri}(x, ..., named_matrix = TRUE) 22 | 23 | \S4method{as.data.frame}{Nri}(x, na.rm = FALSE, ...) 24 | 25 | \S4method{wavelength}{Nri}(object) 26 | 27 | \S4method{dim}{Nri}(x) 28 | 29 | getFiniteNri(x) 30 | } 31 | %- maybe also 'usage' for other objects documented here. 32 | \arguments{ 33 | \item{x,object}{ 34 | Object of class 'Nri' 35 | } 36 | \item{na.rm}{Remove indices containing NA-values. Note that if TRUE, all indices are removed which have at least one NA value.} 37 | \item{named_matrix}{ 38 | Flag if column and row names are set to band indices used for the calculation of the nri-values. 39 | } 40 | \item{...}{ 41 | Further arguments passed to generic functions. Currently ignored. 42 | } 43 | % \item{named_matrix}{ 44 | %Flag if column names should be set to band names and row names to ids of spectra. 45 | %} 46 | 47 | } 48 | 49 | \author{ 50 | Lukas Lehnert 51 | } 52 | 53 | 54 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 55 | 56 | \seealso{ 57 | \code{\link{glm.nri}}, \code{\link{glm}}, \code{\link{nri}} 58 | } -------------------------------------------------------------------------------- /man/normalized.ratio.index.Rd: -------------------------------------------------------------------------------- 1 | \name{nri} 2 | \alias{nri} 3 | %\alias{print.nri} 4 | %\alias{as.matrix.nri} 5 | %- Also NEED an '\alias' for EACH other topic documented here. 6 | \title{ 7 | Normalised ratio index 8 | } 9 | \description{ 10 | Calculate normalised ratio index (nri) for a single given band combination or for all possible band combinations. Calculating nri is a frequently used method to standardize reflectance values and to find relationships between properties of the objects and their spectral data. 11 | } 12 | \usage{ 13 | nri(x, b1, b2, recursive = FALSE, bywavelength = TRUE) 14 | } 15 | %- maybe also 'usage' for other objects documented here. 16 | \arguments{ 17 | \item{x}{ 18 | List of class \code{Speclib} or of class \code{Nri} for print and as.matrix methods. 19 | } 20 | \item{b1}{ 21 | Band 1 given as band number or wavelength. 22 | } 23 | \item{b2}{ 24 | Band 2 given as band number or wavelength. 25 | } 26 | \item{recursive}{ 27 | If TRUE indices for all possible band combinations are calculated. If FALSE, only a single nri for the given bands in \code{b1} and \code{b2} is calculated. 28 | } 29 | \item{bywavelength}{ 30 | Flag to determine if b1 and b2 are band number (bywavelength = FALSE) or wavelength (bywavelength = TRUE) values. 31 | } 32 | % \item{named_matrix}{ 33 | %Flag if column names should be set to band names and row names to ids of spectra. 34 | %} 35 | 36 | } 37 | \details{ 38 | Function for \code{nri} performs the following calculation: 39 | \deqn{nri_{B1,~B2}=\frac{R_{B1}-R_{B2}}{R_{B1}-R_{B2}};} 40 | with \eqn{R} being reflectance values at wavelength \eqn{B1} and \eqn{B2}, respectively. 41 | 42 | If recursive = TRUE, all possible band combinations are calculated. 43 | } 44 | \value{ 45 | If recursive = FALSE, a data frame with index values is returned. Otherwise result is an object of class \code{\linkS4class{Nri}}. See \code{\link{glm.nri}} for applying a generalised linear model to an array of normalised ratio indices. 46 | } 47 | 48 | \references{ 49 | Sims, D.A.; Gamon, J.A. (2002). Relationships between leaf pigment content and spectral reflectance across a wide range of species, leaf structures and developmental stages. Remote Sensing of Environment: 81/2, 337 - 354. 50 | 51 | Thenkabail, P.S.; Smith, R.B.; Pauw, E.D. (2000). Hyperspectral vegetation indices and their relationships with agricultural crop characteristics. Remote Sensing of Environment: 71/2, 158 - 182. 52 | } 53 | 54 | \author{ 55 | Lukas Lehnert 56 | } 57 | 58 | 59 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 60 | 61 | \seealso{ 62 | \code{\link{glm.nri}}, \code{\link{glm}}, \code{\linkS4class{Speclib}}, \code{\linkS4class{Nri}} 63 | } 64 | \examples{ 65 | data(spectral_data) 66 | 67 | ## Calculate NDVI 68 | ndvi <- nri(spectral_data, b1=800, b2=680) 69 | 70 | ## Calculate all possible combinations for WorldView-2-8 71 | spec_WV <- spectralResampling(spectral_data, "WorldView2-8", 72 | response_function = FALSE) 73 | nri_WV <- nri(spec_WV, recursive = TRUE) 74 | nri_WV 75 | } 76 | % Add one or more standard keywords, see file 'KEYWORDS' in the 77 | % R documentation directory. 78 | \keyword{multivariate} 79 | -------------------------------------------------------------------------------- /man/normalized.ratio.index.best.perfomance.Rd: -------------------------------------------------------------------------------- 1 | \name{nri_best_performance} 2 | \alias{nri_best_performance} 3 | \alias{mark_nri_best_performance} 4 | %- Also NEED an '\alias' for EACH other topic documented here. 5 | \title{ 6 | Best performing model(s) with NRI 7 | } 8 | \description{ 9 | Get or mark best performing model(s) between narrow band indices and environmental variables 10 | } 11 | \usage{ 12 | nri_best_performance(nri, n = 1, coefficient = "p.value", 13 | predictor = 2, abs = FALSE, findMax = FALSE, 14 | ...) 15 | mark_nri_best_performance(best, glmnri, n = nrow(best$Indices), 16 | uppertriang = FALSE, ...) 17 | } 18 | %- maybe also 'usage' for other objects documented here. 19 | \arguments{ 20 | \item{nri}{ 21 | Object of class nri 22 | } 23 | \item{glmnri}{ 24 | Object of class glmnri 25 | } 26 | \item{n}{ 27 | Number of models to return or mark 28 | } 29 | \item{coefficient}{ 30 | Name or index of coefficient to plot 31 | } 32 | \item{predictor}{ 33 | Name or index of term to plot 34 | } 35 | \item{abs}{ 36 | Use absolute value (e.g. for t-values) 37 | } 38 | \item{findMax}{ 39 | Find maximum or minimum values 40 | } 41 | \item{best}{ 42 | Output from \code{nri_best_performance} 43 | } 44 | \item{uppertriang}{ 45 | Flag to mark the upper triangle 46 | } 47 | \item{...}{ 48 | Further arguments passed to \code{\link{glm}} function. These must be the same as used for initial creation of \code{\link{glm.nri}}. For \code{mark_nri_best_performance} arguments are passed to \code{\link{polygon}}. 49 | } 50 | } 51 | \details{ 52 | See details in \code{\link{glm.nri}} and \code{\link{glm}}. 53 | } 54 | 55 | \author{ 56 | Lukas Lehnert 57 | } 58 | 59 | 60 | \seealso{ 61 | \code{\link{glm.nri}}, \code{\link{glm}} 62 | } 63 | \examples{ 64 | data(spectral_data) 65 | 66 | ## Calculate all possible combinations for WorldView-2-8 67 | spec_WV <- spectralResampling(spectral_data, "WorldView2-8", 68 | response_function = FALSE) 69 | nri_WV <- nri(spec_WV, recursive = TRUE) 70 | 71 | ## Build glm-models 72 | glmnri <- glm.nri(nri_WV ~ chlorophyll, preddata = spec_WV) 73 | 74 | ## Return best 5 models 75 | BM <- nri_best_performance(glmnri, n = 5, coefficient = "p.value") 76 | 77 | ## Get nri values for the 5 models 78 | nri_BM <- getNRI(nri_WV, BM) 79 | } 80 | % Add one or more standard keywords, see file 'KEYWORDS' in the 81 | % R documentation directory. 82 | \keyword{multivariate} 83 | -------------------------------------------------------------------------------- /man/plot.specfeat.Rd: -------------------------------------------------------------------------------- 1 | \name{plot.Specfeat} 2 | \alias{plot.Specfeat} 3 | \alias{plot,Specfeat,ANY-method} 4 | \alias{plot,Specfeat-method} 5 | \title{ 6 | Plot Specfeat 7 | } 8 | \description{ 9 | Plot spectra in objects of class \code{\linkS4class{Specfeat}}. Specfeats contain spectral data after applying a transformation such as continuum removal (see function \code{\link{transformSpeclib}}. 10 | } 11 | \usage{ 12 | \S4method{plot}{Specfeat}(x, fnumber = 1:n_features(x), stylebysubset = NULL, 13 | changecol = TRUE, changetype = FALSE, autolegend = TRUE, new = TRUE, 14 | ...) 15 | } 16 | %- maybe also 'usage' for other objects documented here. 17 | \arguments{ 18 | \item{x}{ 19 | Object to be plotted 20 | } 21 | \item{fnumber}{ 22 | Subscript of feature(s) to be plotted 23 | } 24 | \item{stylebysubset}{ 25 | Name of column in SI table to be used for colour. 26 | } 27 | \item{changecol}{ 28 | Flag indicating if line colours change according to values in coloumn defined by stylebysubset 29 | } 30 | \item{changetype}{ 31 | Flag indicating if line types change according to values in coloumn defined by stylebysubset 32 | } 33 | \item{autolegend}{ 34 | Flag if legend is plotted. 35 | } 36 | \item{new}{ 37 | Flag if a new plot should be started. 38 | } 39 | \item{...}{ 40 | Further arguments passed to \code{plot.default} 41 | } 42 | } 43 | 44 | 45 | \author{ 46 | Lukas Lehnert 47 | } 48 | 49 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 50 | 51 | \seealso{ 52 | \code{\link{nri}}, \code{\link{glm.nri}}, \code{\link{glm}}, \code{\link{cor.test,Nri-method}}, \code{\link{t.test,Nri-method}}, \code{\linkS4class{Specfeat}} 53 | } 54 | \examples{ 55 | \dontrun{ 56 | data(spectral_data) 57 | 58 | ## Transform speclib 59 | bd <- transformSpeclib(spectral_data, method = "sh", out = "bd") 60 | 61 | ##Example to isolate the features around 450nm, 700nm, 1200nm and 1500nm. 62 | featureSelection <- specfeat(bd, c(450,700,1200,1500)) 63 | 64 | ## Plot features 65 | plot(featureSelection) 66 | 67 | ## Advanced plotting example 68 | plot(featureSelection, 1:2, stylebysubset = "season") 69 | 70 | plot(featureSelection, 1:2, stylebysubset = "season", changecol = FALSE, 71 | changetype = TRUE) 72 | } 73 | } 74 | % Add one or more standard keywords, see file 'KEYWORDS' in the 75 | % R documentation directory. 76 | \keyword{aplot} 77 | -------------------------------------------------------------------------------- /man/plot.speclib.Rd: -------------------------------------------------------------------------------- 1 | \name{plot.Speclib} 2 | \alias{plot.Speclib} 3 | \alias{plot,Speclib,ANY-method} 4 | \alias{plot,Speclib-method} 5 | \alias{legendSpeclib} 6 | %- Also NEED an '\alias' for EACH other topic documented here. 7 | \title{ 8 | Plot speclib 9 | } 10 | \description{ 11 | Plot \code{Speclib} in a new plot or adding it to an existing plot. 12 | } 13 | \usage{ 14 | \S4method{plot}{Speclib}(x, FUN = NULL, new = TRUE, ...) 15 | } 16 | %- maybe also 'usage' for other objects documented here. 17 | \arguments{ 18 | \item{x}{ 19 | Object of class \code{Speclib}. 20 | } 21 | \item{FUN}{ 22 | Name of a function (character) or index or ID of single spectrum to plot (integer). 23 | } 24 | \item{new}{ 25 | If FALSE the plot is added to active existing plot. 26 | } 27 | \item{...}{ 28 | Further arguments passed to internal plot functions. 29 | } 30 | } 31 | \details{ 32 | The function may work in a couple of modes. The default way is to plot mean values (solid line) of all spectra and the standard deviations within bands. If data is assumed to be continuous the standard deviations are plotted as dashed lines otherwise error bars will indicate standard deviations. 33 | 34 | The user has various options to change the way things are looking: With argument \code{FUN} the name of a function, the ID or the index of a certain spectrum may be specified. Note that if \code{FUN} is a function, this function will be applied to all spectra. If function should be applied to a subset of spectra, use function \code{\link[=subset.speclib]{subset}} to define rules excluding certain spectra. 35 | 36 | By passing a subset, the user may specify a spectral range to plot. Limits for x- and y-axis will be found automatically or may be passed separately. 37 | } 38 | 39 | \author{ 40 | Lukas Lehnert 41 | } 42 | 43 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 44 | 45 | \seealso{ 46 | \code{\linkS4class{Speclib}} 47 | } 48 | \examples{ 49 | data(spectral_data) 50 | 51 | ## Set mask for channel crossing and water absorption bands 52 | mask(spectral_data) <- c(1040, 1060, 1350, 1450) 53 | 54 | ## Simple example 55 | plot(spectral_data, legend = list(x = "topleft")) 56 | 57 | ## Example with function 58 | par(mfrow = c(2,3)) 59 | plot(spectral_data, FUN = "min", main = "Minimum of speclib") 60 | plot(spectral_data, FUN = "max", main = "Maximum of speclib") 61 | plot(spectral_data, FUN = "median", main = "Median of speclib") 62 | plot(spectral_data, FUN = "mean", main = "Mean of speclib") 63 | plot(spectral_data, FUN = "var", main = "Variance of speclib") 64 | 65 | } 66 | 67 | % ## Example with groups 68 | % plot(spectral_data, bygroups = TRUE, legend = list(x = "topleft")) 69 | % Add one or more standard keywords, see file 'KEYWORDS' in the 70 | % R documentation directory. 71 | \keyword{aplot} 72 | -------------------------------------------------------------------------------- /man/postprocess_ASD.Rd: -------------------------------------------------------------------------------- 1 | \name{postprocessASD} 2 | \alias{postprocessASD} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Read ASD binary file 6 | } 7 | \description{ 8 | Read spectra stored in ASD binary files using the package 'asdreader'. 9 | } 10 | \usage{ 11 | postprocessASD(x, reference, removeCrossings = TRUE, 12 | correctReflectance = TRUE) 13 | } 14 | %- maybe also 'usage' for other objects documented here. 15 | \arguments{ 16 | \item{x}{ 17 | Object of class 'Speclib' containing spectra to be processed. 18 | } 19 | \item{reference}{ 20 | Object of class 'Speclib' containing single reference spectrum (sensitivity of the white reference standard). 21 | } 22 | \item{removeCrossings}{ 23 | Flag if channel crossings at 1000 nm and 1800 nm should be removed. 24 | } 25 | \item{correctReflectance}{ 26 | Flag if reflectance values should be corrected using the spectrum of the reference. 27 | } 28 | } 29 | \author{ 30 | Lukas Lehnert 31 | } 32 | \value{ 33 | Object of class \code{Speclib}. 34 | } 35 | \seealso{ 36 | \code{\link{speclib}} 37 | } 38 | 39 | \keyword{ utilities } 40 | -------------------------------------------------------------------------------- /man/raster-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{Raster-methods} 2 | \alias{Raster-methods} 3 | % \alias{extract,Speclib,ANY-method} 4 | \alias{extract,Speclib-method} 5 | \alias{writeRaster,Speclib,character-method} 6 | \alias{plotRGB,Speclib-method} 7 | \alias{brick,Speclib-method} 8 | 9 | \title{Rasterbased methods for spectra} 10 | 11 | \description{ 12 | Methods to manipulate, save, convert and plot spectra in Speclibs stored as RasterBrick 13 | } 14 | 15 | \usage{ 16 | \S4method{extract}{Speclib}(x, y, ...) 17 | 18 | \S4method{writeRaster}{Speclib,character}(x, filename, ...) 19 | 20 | \S4method{plotRGB}{Speclib}(x, ...) 21 | 22 | \S4method{brick}{Speclib}(x, ...) 23 | } 24 | 25 | \arguments{ 26 | \item{x}{Speclib with RasterBrick-object for spectra} 27 | \item{y}{Object of any valid type to define area to extract} 28 | \item{filename}{Output filename} 29 | \item{...}{Additionaly arguments passed to basic funtions in the raster-package} 30 | } 31 | 32 | 33 | \details{ 34 | For \code{extract}, a \code{Speclib} is returned containing the data of \code{y} in the \code{SI}. Note that if \code{y} is a buffer, spatial lines or spatial polygon object, the respective data in \code{y} is copied for each spectrum so that the length of the \code{SI} equals the number of spectra. 35 | 36 | For \code{writeRaster}, the Speclib is returned which is written to file. Please note that data in the SI and the wavelength information cannot be stored in a raster file at present. Therefore, it should be considered to store the entire Speclib as R-data file using the \code{\link{save}}-function in R. 37 | 38 | Note for function \code{brick} that by default the values of the internal brick in the Speclib are copied to the new object. However, new brick objects with differing dimensions, bands etc. may be created if \code{values == FALSE} is passed as additional arguement. 39 | } 40 | \value{ 41 | \code{Speclib} for \code{extract} and \code{writeRaster}. Object of class \code{Brick} for \code{brick}. 42 | } 43 | \author{ 44 | Lukas Lehnert 45 | } 46 | 47 | \keyword{ spatial } 48 | \keyword{ methods } -------------------------------------------------------------------------------- /man/rastermeta.Rd: -------------------------------------------------------------------------------- 1 | \name{rastermeta} 2 | \alias{rastermeta} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Create list containing rastermeta-information 6 | } 7 | \description{ 8 | Create valid objects for slot \code{rastermeta} in \code{\linkS4class{Speclib}}. 9 | } 10 | \usage{ 11 | rastermeta(x, dim, ext, crs) 12 | } 13 | %- maybe also 'usage' for other objects documented here. 14 | \arguments{ 15 | \item{x}{ 16 | Optional. Object of one of the following classes: "Raster", "RasterBrick", "RasterStack", "HyperSpecRaster". 17 | } 18 | \item{dim}{ 19 | Optional. Vector with length == 2. The first and second elements give the number of rows and columns, respectively. 20 | } 21 | \item{ext}{ 22 | Optional. Object of class \code{extent}. 23 | } 24 | \item{crs}{ 25 | Optional. Object of class \code{CRS}. 26 | } 27 | } 28 | \author{ 29 | Lukas Lehnert 30 | } 31 | \value{ 32 | List with following elements (in exactly this order!): 33 | \itemize{ 34 | \item{dim:}{ Vector with length == 2. The first and second elements give the number of rows and columns, respectively.} 35 | \item{ext:}{ Object of class \code{extent}.} 36 | \item{crs:}{ Object of class \code{CRS}.} 37 | } 38 | } 39 | \seealso{ 40 | \code{\linkS4class{Speclib}}, \code{\linkS4class{HyperSpecRaster}} 41 | } 42 | 43 | -------------------------------------------------------------------------------- /man/read.header.Rd: -------------------------------------------------------------------------------- 1 | \name{read_header} 2 | \alias{read_header} 3 | 4 | 5 | \title{Get reflectance values} 6 | \description{ 7 | Read ENVI header file 8 | } 9 | 10 | \usage{ 11 | read_header(file, ...) 12 | 13 | } 14 | \arguments{ 15 | \item{file}{ 16 | Path of file to be read. 17 | } 18 | \item{...}{ 19 | Arguments to be passed to specific functions. Currently ignored. 20 | } 21 | } 22 | \value{ 23 | A named list containing the information in the header file 24 | } 25 | \author{ Lukas Lehnert } 26 | 27 | -------------------------------------------------------------------------------- /man/read_ASD.Rd: -------------------------------------------------------------------------------- 1 | \name{read.ASD} 2 | \alias{read.ASD} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Read ASD binary file 6 | } 7 | \description{ 8 | Read spectra stored in ASD binary files using the package 'asdreader'. 9 | } 10 | \usage{ 11 | read.ASD(f, type = "reflectance", ...) 12 | } 13 | %- maybe also 'usage' for other objects documented here. 14 | \arguments{ 15 | \item{f}{ 16 | Vector with files names to be read. 17 | } 18 | \item{type}{ 19 | Character vector, which type of spectra to return. See ?get_spectra for options. 20 | } 21 | \item{...}{ 22 | Additional arguments passed to get_spectra. Currently ignored. 23 | } 24 | } 25 | 26 | 27 | \author{ 28 | Lukas Lehnert 29 | } 30 | \value{ 31 | Object of class \code{Speclib}. 32 | } 33 | \seealso{ 34 | \code{\link{speclib}} 35 | } 36 | 37 | \keyword{ utilities } 38 | -------------------------------------------------------------------------------- /man/rededge.Rd: -------------------------------------------------------------------------------- 1 | \name{rededge} 2 | \alias{rededge} 3 | \title{ 4 | Red edge parameter 5 | } 6 | \description{ 7 | Derive red edge parameters from hyperspectral data. Red edge is the sharp increase of reflectance values in the near infrared. 8 | } 9 | \usage{ 10 | rededge(x) 11 | } 12 | \arguments{ 13 | \item{x}{ 14 | List of class \code{Speclib} 15 | } 16 | } 17 | \details{ 18 | Shape and location of the red edge are commonly described by four parameters: 19 | \itemize{ 20 | \item{\eqn{\lambda 0}{l0}: }{wavelength of the minimum reflectance in the red spectrum} 21 | \item{\eqn{\lambda p}{lp}: }{wavelength of the inflection point} 22 | \item{\eqn{\lambda s}{ls}: }{wavelength of the reflectance shoulder} 23 | \item{\eqn{R0}: }{reflectance at l0} 24 | \item{\eqn{Rp}: }{Reflectance at lp} 25 | \item{\eqn{Rs}: }{Reflectance at ls} 26 | } 27 | 28 | The red edge parameters are calculated as proposed in Bach (1995) from the spectral area between 550 and 900 nm. 29 | \eqn{\lambda 0}{l0} is calculated as the last root before the maximum value of the 2nd derivation. 30 | The minimum reflectance is the reflectance at (\eqn{\lambda 0}{l0}). 31 | The inflection point is the root of the 2nd derivative function between the maximum value and 32 | the minimum value. The shoulder wavelength is the first root beyond the minimum value of the 2nd derivation. The following figure shows the locaqtion of the red edge parameters in an example second derivation and reflectance spectrum. 33 | 34 | \if{html}{\figure{rededge.png}{options: width="35\%" alt="Figure: rededge.png"}} 35 | \if{latex}{\figure{rededge.pdf}{options: width=10cm}} 36 | 37 | } 38 | \value{ 39 | A data frame containing parameters for each spectrum. 40 | } 41 | \references{ 42 | Bach, H. (1995): Die Bestimmung hydrologischer und landwirtschaftlicher Oberflaechenparameter aus hyperspektralen Fernerkundungsdaten. 43 | Muenchner Geographische Abhandlungen Reihe B, Band B21. 44 | 45 | } 46 | \author{ 47 | Hanna Meyer 48 | } 49 | 50 | \seealso{ 51 | \code{\link{vegindex}}, \code{\link{derivative.speclib}}, \code{\link{noiseFiltering}} 52 | } 53 | \examples{ 54 | # compare R0 for spectra taken in different seasons 55 | data(spectral_data) 56 | rd <- rededge(spectral_data) 57 | boxplot(rd$R0 ~ SI(spectral_data)$season, ylab = "R0") 58 | 59 | # visualize red edge parameter of one spectrum 60 | plot(spectral_data[1,],xlim=c(500,900),ylim=c(0,50)) 61 | plot(spectral_data[1,],xlim=c(500,900),ylim=c(0,50)) 62 | x <- c(rd$l0[1], rd$lp[1], rd$ls[1]) 63 | y <- c(rd$R0[1], rd$Rp[1], rd$Rs[1]) 64 | points(x, y) 65 | text(x, y, c("l0", "lp", "ls"), pos = 3, offset = 1) 66 | } 67 | \keyword{multivariate} 68 | -------------------------------------------------------------------------------- /man/sensorCharacteristics.Rd: -------------------------------------------------------------------------------- 1 | \name{get.sensor.characteristics} 2 | \alias{get.sensor.characteristics} 3 | \alias{list.available.sensors} 4 | %- Also NEED an '\alias' for EACH other topic documented here. 5 | \title{ 6 | Sensor characteristics 7 | } 8 | \description{ 9 | Get channel wavelength of implemented (multispectral) satellite sensors. 10 | } 11 | \usage{ 12 | get.sensor.characteristics(sensor, response_function = FALSE) 13 | } 14 | %- maybe also 'usage' for other objects documented here. 15 | \arguments{ 16 | \item{sensor}{ 17 | Character or integer. Name or numerical abbreviation of sensor. See 'sensor="help"' or 'sensor=0' for an overview of available sensors. 18 | } 19 | \item{response_function}{ 20 | If TRUE, the spectral response function is returned. 21 | } 22 | } 23 | \details{ 24 | The following sensors are currently implemented: \Sexpr[echo=TRUE,results=text]{ 25 | paste(row.names(hsdar:::get.sensor.characteristics(0)), collapse = ", ") 26 | }. 27 | 28 | Spectral response functions are available for the following ones: \Sexpr[echo=TRUE,results=text]{ 29 | paste(row.names(hsdar:::get.sensor.characteristics(0))[hsdar:::get.sensor.characteristics(0)[,2]], collapse = ", ") 30 | }. 31 | } 32 | 33 | \author{ 34 | Lukas Lehnert 35 | } 36 | 37 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 38 | 39 | \seealso{ 40 | \code{\link{spectralResampling}} 41 | } 42 | \examples{ 43 | ## Return implemented sensors 44 | get.sensor.characteristics(0) 45 | 46 | ## Sentinel 2A 47 | data_s2a <- get.sensor.characteristics("Sentinel2a", TRUE) 48 | 49 | ## Plot response functions 50 | plot(c(0,1)~c(attr(data_s2a$response, "minwl"), 51 | attr(data_s2a$response, "maxwl")), 52 | type = "n", xlab = "Wavelength [nm]", 53 | ylab = "Spectral response") 54 | xwl_response <- seq.int(attr(data_s2a$response, "minwl"), 55 | attr(data_s2a$response, "maxwl"), 56 | attr(data_s2a$response, "stepsize")) 57 | for (i in 1:nrow(data_s2a$characteristics)) 58 | lines(xwl_response, data_s2a$response[,i], col = i) 59 | 60 | 61 | 62 | ## Sentinel 2B 63 | data_s2b <- get.sensor.characteristics("Sentinel2b", TRUE) 64 | 65 | ## Add response functions 66 | for (i in 1:nrow(data_s2b$characteristics)) 67 | lines(xwl_response, data_s2b$response[,i], col = i, lty = "dashed") 68 | legend("topright", legend = c("Sentinel2a", "Sentinel2b"), 69 | lty = c("solid", "dashed")) 70 | 71 | 72 | 73 | 74 | } 75 | % Add one or more standard keywords, see file 'KEYWORDS' in the 76 | % R documentation directory. 77 | \keyword{utilities} 78 | -------------------------------------------------------------------------------- /man/simple.ratio.index.Rd: -------------------------------------------------------------------------------- 1 | \name{sr} 2 | \alias{sr} 3 | \title{ 4 | Simple ratio index 5 | } 6 | \description{ 7 | Calculate simple ratio index (sr) for a single given band combination or for all possible band combinations. Calculating sr is a frequently used method to standardize reflectance values and to find relationships between properties of the objects and their spectral data. 8 | } 9 | \usage{ 10 | sr(x, b1, b2, recursive = FALSE, bywavelength = TRUE) 11 | } 12 | %- maybe also 'usage' for other objects documented here. 13 | \arguments{ 14 | \item{x}{ 15 | List of class \code{Speclib} or of class \code{Nri} for print and as.matrix methods. 16 | } 17 | \item{b1}{ 18 | Band 1 given as band number or wavelength. 19 | } 20 | \item{b2}{ 21 | Band 2 given as band number or wavelength. 22 | } 23 | \item{recursive}{ 24 | If TRUE indices for all possible band combinations are calculated. If FALSE, only a single sr for the given bands in \code{b1} and \code{b2} is calculated. 25 | } 26 | \item{bywavelength}{ 27 | Flag to determine if b1 and b2 are band number (bywavelength = FALSE) or wavelength (bywavelength = TRUE) values. 28 | } 29 | } 30 | 31 | \details{ 32 | Function performs the following calculation: 33 | \deqn{nri_{B1,~B2}=\frac{R_{B1}}{R_{B2}};} 34 | with \eqn{R} being reflectance values at wavelength \eqn{B1} and \eqn{B2}, respectively. 35 | 36 | If recursive = TRUE, all possible band combinations are calculated. 37 | } 38 | \value{ 39 | If recursive = FALSE, a data frame with index values is returned. Otherwise result is an object of class \code{\linkS4class{Nri}}. See \code{\link{glm.nri}} for applying a generalised linear model to an array of simple ratio indices. 40 | } 41 | 42 | \author{ 43 | Lukas Lehnert 44 | } 45 | 46 | 47 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 48 | 49 | \seealso{ 50 | \code{\link{nri}}, \code{\link{glm.nri}}, \code{\link{glm}}, \code{\linkS4class{Speclib}}, \code{\linkS4class{Nri}} 51 | } 52 | \examples{ 53 | data(spectral_data) 54 | 55 | ## Calculate SR of Jordan (1969) (R_{800}/R_{680}) 56 | sr_600_680 <- sr(spectral_data, b1=800, b2=680) 57 | 58 | ## Calculate all possible combinations for WorldView-2-8 59 | spec_WV <- spectralResampling(spectral_data, "WorldView2-8", 60 | response_function = FALSE) 61 | sr_WV <- sr(spec_WV, recursive = TRUE) 62 | sr_WV 63 | } 64 | % Add one or more standard keywords, see file 'KEYWORDS' in the 65 | % R documentation directory. 66 | \keyword{multivariate} 67 | -------------------------------------------------------------------------------- /man/smgm.Rd: -------------------------------------------------------------------------------- 1 | \name{smgm} 2 | \alias{smgm} 3 | \title{ 4 | SMGM 5 | } 6 | \description{ 7 | Calculate Gaussian model on soil spectra 8 | } 9 | \usage{ 10 | smgm(x, percentage = TRUE, gridsize = 50) 11 | } 12 | %- maybe also 'usage' for other objects documented here. 13 | \arguments{ 14 | \item{x}{ 15 | Object of class Speclib. 16 | } 17 | \item{percentage}{ 18 | Flag if spectra in x are in range [0, 100]. If FALSE, the spectra are scaled to [0,100]. 19 | } 20 | \item{gridsize}{ 21 | Size of the grid used to perform least squares approximation. 22 | } 23 | } 24 | \author{ 25 | Lukas Lehnert 26 | } 27 | \details{ 28 | The algorithm fits a Gaussian function to the continuum points of the spectra in the spectral region between approx. 1500 to 2500 nm. The continuum points are derived constructing the convex hull of the spectra (see \code{\link{transformSpeclib}}). The Gaussian function requires three parameter: (1) the mean values which is set to the water fundamental of 2800 nm, (2) the absorption depth at 2800 nm, and (3) the distance to the inflection point of the function. The latter two parameters are iteratively chosen using a grid search. The mesh size of the grid can be adjusted with the \code{gridsize} parameter. Note that the function requires the spectral reflectance values to be in interval [0, 100]. 29 | } 30 | \value{ 31 | Object of class \code{Speclib} containing the fitted Gaussian spectra and the parameters derived from the Gaussian curve. The three parameters (absorption depth, R0; distance to the inflection point, sigma; area between the curve and 100 \% reflectance, area) are stored in the SI of the new Speclib. Additionally, the function returns the final root mean square error of the Gaussian fit. 32 | } 33 | \references{ 34 | Whiting, M. L., Li, L. and Ustin, S. L. (2004): Predicting water content using Gaussian model on soil spectra. Remote Sensing of Environment, 89, 535-552. 35 | } 36 | \note{ 37 | The code is based on the IDL functions written by Michael L. Whiting. 38 | } 39 | \seealso{ 40 | \code{\link{soilindex}}, \linkS4class{Speclib} 41 | } 42 | 43 | \examples{ 44 | ## Use PROSAIL to simulate spectra with different soil moisture content 45 | Spektr.lib <- noiseFiltering(PROSAIL(parameterList = data.frame(psoil = seq(0,1,0.1), 46 | LAI = 0))) 47 | 48 | smgm_val <- smgm(Spektr.lib) 49 | 50 | for (i in 1:nspectra(smgm_val)) 51 | plot(smgm_val, FUN = i, new = i==1, col = i) 52 | 53 | SI(smgm_val) 54 | } 55 | -------------------------------------------------------------------------------- /man/specfeat.Rd: -------------------------------------------------------------------------------- 1 | \name{specfeat} 2 | \alias{specfeat} 3 | \alias{[,Specfeat,ANY,ANY,ANY-method} 4 | \alias{n_features} 5 | \alias{n_features,Specfeat-method} 6 | %- Also NEED an '\alias' for EACH other topic documented here. 7 | \title{ 8 | Function to isolate absorption features 9 | } 10 | \description{ 11 | Function isolates absorption features from band depth or ratio transformed reflectance spectra. 12 | } 13 | \usage{ 14 | specfeat(x, FWL, tol = 1.0e-7) 15 | } 16 | %- maybe also 'usage' for other objects documented here. 17 | \arguments{ 18 | \item{x}{ 19 | Object of class \code{Speclib} containing the band depth or ratio transformed reflectance spectra. 20 | } 21 | \item{FWL}{ 22 | A vector containing one wavelength included in each feature to be isolated, e.g. the major absorption features. 23 | Features which include these specified wavelengths will be isolated. 24 | } 25 | \item{tol}{ 26 | The tolerance of the band depth which defines a wavelength as a start or end point of a feature. 27 | Usually a band depth of 0 or a ratio of 1 indicates feature limits, however, 28 | better results are achieved if slightly deviating values are tolerated. 29 | } 30 | } 31 | 32 | \details{ 33 | A feature is defined as the part of the spectrum between two fix points in the transformed spectra (band depth values of 0). This function separates features at wavelengths of interest according to this rule. 34 | Hence it allows a subsequent characterization of the features of interest, e.g. via 35 | \code{\link{feature_properties}} or visual inspection via \code{\link{plot.Specfeat}}. 36 | The typical workflow to obtain feature properties is to first calculate 37 | the band depth \code{\link{transformSpeclib}}, then isolate the absorption features 38 | \code{\link{specfeat}}. Optionally, \code{\link{cut_specfeat}} allows to cut the features at specified wavelengths. Finally use \code{\link{feature_properties}} to retrieve characteristics of the features. 39 | } 40 | 41 | \value{ 42 | An object of class \code{Specfeat} containing the isolated features. 43 | } 44 | 45 | \author{ 46 | Hanna Meyer and Lukas Lehnert 47 | } 48 | 49 | \seealso{ 50 | \code{\link{transformSpeclib}}, \code{\link{cut_specfeat}}, \linkS4class{Specfeat}, \code{\link{plot.Specfeat}}, 51 | \code{\link{feature_properties}} 52 | } 53 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 54 | \examples{ 55 | % \dontrun{ 56 | data(spectral_data) 57 | 58 | ## Transform speclib 59 | bd <- transformSpeclib(spectral_data, method = "sh", out = "bd") 60 | 61 | ##Example to isolate the features around 450nm, 700nm, 1200nm and 1500nm. 62 | featureSelection <- specfeat(bd, c(450,700,1200,1500)) 63 | 64 | ## Plot features 65 | plot(featureSelection) 66 | 67 | ## Advanced plotting example 68 | plot(featureSelection, 1:2, stylebysubset = "season") 69 | 70 | plot(featureSelection, 1:2, stylebysubset = "season", changecol = FALSE, 71 | changetype = TRUE) 72 | % } 73 | } 74 | \keyword{classes} 75 | \keyword{aplot} -------------------------------------------------------------------------------- /man/speclib_indexing.Rd: -------------------------------------------------------------------------------- 1 | \name{Extract Speclib by index} 2 | \alias{[,Speclib,ANY,ANY-method} 3 | \alias{[,Speclib,ANY,ANY,ANY-method} 4 | \alias{[,Speclib-method} 5 | %- Also NEED an '\alias' for EACH other topic documented here. 6 | \title{ 7 | Indexing Speclib 8 | } 9 | \description{ 10 | Access subsets of data in Speclibs both in spectrals and sample dimensions 11 | } 12 | \usage{ 13 | \S4method{[}{Speclib}(x, i, j, ...) 14 | } 15 | %- maybe also 'usage' for other objects documented here. 16 | \arguments{ 17 | \item{x}{ 18 | Object of class \code{Speclib} to be indexed. 19 | } 20 | \item{i}{ 21 | Samples to be returned. 22 | } 23 | \item{j}{ 24 | Bands to be returned. 25 | } 26 | \item{...}{ 27 | Further arguements (currently ignored). 28 | } 29 | } 30 | \details{ 31 | The first index represents the sample dimension and the second one is the band dimension. If the sample dimension is indexed, care is taken that the SI and the id is indexed as well. 32 | } 33 | 34 | \author{ 35 | Lukas Lehnert 36 | } 37 | \value{ 38 | Object of class \code{Speclib} containing the updated version of x. 39 | } 40 | \seealso{ 41 | \code{\linkS4class{Speclib}}, \code{\link{subset.speclib}}, \code{\link{SI}}, \code{\link{idSpeclib}} 42 | } 43 | 44 | \examples{ 45 | data(spectral_data) 46 | 47 | ## Get the first five spectra 48 | spec_1_5 <- spectral_data[1:5,] 49 | spec_1_5 50 | 51 | ## Get the first ten bands 52 | spec_1_10 <- spectral_data[,1:10] 53 | spec_1_10 54 | 55 | ## Get the bands number 20 to 30 for the third and fifth spectra 56 | spec_20_30 <- spectral_data[c(3,5),20:30] 57 | spec_20_30 58 | } 59 | \keyword{ utilities } 60 | -------------------------------------------------------------------------------- /man/spectra.Rd: -------------------------------------------------------------------------------- 1 | \name{spectra} 2 | \alias{spectra.Speclib} 3 | \alias{spectra} 4 | \alias{spectra<-} 5 | \alias{spectra,Speclib-method} 6 | \alias{spectra<-,Speclib,data.frame-method} 7 | \alias{spectra<-,Speclib,matrix-method} 8 | \alias{spectra<-,Speclib,numeric-method} 9 | \alias{spectra<-,Speclib,RasterBrick-method} 10 | \alias{[,.Spectra,ANY,ANY,ANY-method} 11 | \alias{show,.Spectra-method} 12 | \alias{print,.Spectra-method} 13 | 14 | 15 | % Die Raster-methods sollten noch separat ausgegliedert werden 16 | \alias{cellFromCol,Speclib-method} 17 | \alias{cellFromLine,Speclib-method} 18 | \alias{cellFromPolygon,Speclib-method} 19 | \alias{cellFromRow,Speclib-method} 20 | \alias{cellFromRowCol,Speclib-method} 21 | \alias{cellFromRowColCombine,Speclib-method} 22 | \alias{cellFromXY,Speclib-method} 23 | \alias{colFromX,Speclib-method} 24 | \alias{fourCellsFromXY,Speclib-method} 25 | \alias{rowFromY,Speclib-method} 26 | \alias{readAll,Speclib-method} 27 | 28 | 29 | \title{ 30 | Handling spectra 31 | } 32 | \description{ 33 | Returning and setting spectra in Speclib 34 | } 35 | \usage{ 36 | \S4method{spectra}{Speclib}(object, i, j, ...) 37 | 38 | \S4method{spectra}{Speclib,data.frame}(object) <- value 39 | 40 | \S4method{spectra}{Speclib,matrix}(object) <- value 41 | 42 | \S4method{spectra}{Speclib,numeric}(object) <- value 43 | 44 | \S4method{spectra}{Speclib,RasterBrick}(object) <- value 45 | } 46 | \arguments{ 47 | \item{object}{ 48 | Object of class \code{Speclib}. 49 | } 50 | \item{i}{ 51 | Index of spectra to return. If missing all spectra are returned. 52 | } 53 | \item{j}{ 54 | Index of bands to return. If missing all bands are returned. 55 | } 56 | \item{...}{ 57 | Passed to internal function. Currently only one parameter is accepted: \code{return_names}: Logical indicating, if names of columns and rows should be set to \code{\link{bandnames}} and \code{\link{idSpeclib}}. 58 | } 59 | \item{value}{ 60 | Matrix or RasterBrick-object containing spectral values. If value is a matrix, columns are band values and rows are spectra. 61 | } 62 | } 63 | \details{ 64 | For \code{spectra<-}, the function does not check if dimensions of spectra match dimensions of Speclib. Additionally, no conversion into \code{matrix} is performed! If spectra are not correctly stored, errors in other functions may arise. Thus check always carefully, if spectra are modified by hand. 65 | } 66 | \value{ 67 | For \code{spectra<-}, the updated object. Otherwise a matrix of the spectra in x is returned. 68 | } 69 | 70 | \author{ 71 | Lukas Lehnert 72 | } 73 | 74 | 75 | \seealso{ 76 | \code{\linkS4class{Speclib}} 77 | } 78 | \examples{ 79 | data(spectral_data) 80 | 81 | ## Manual plot of the first spectrum 82 | plot(wavelength(spectral_data), spectra(spectral_data)[1,], type="l") 83 | } 84 | \keyword{utilities} 85 | -------------------------------------------------------------------------------- /man/spectralInterpolation.Rd: -------------------------------------------------------------------------------- 1 | \name{spectralInterpolation} 2 | \alias{spectralInterpolation} 3 | %- Also NEED an '\alias' for EACH other topic documented here. 4 | \title{ 5 | Interpolate spectra 6 | } 7 | \description{ 8 | Interpolate spectra to user defined bands. Currently, only a linear interpolation is supported 9 | } 10 | \usage{ 11 | spectralInterpolation(x, sensor) 12 | } 13 | %- maybe also 'usage' for other objects documented here. 14 | \arguments{ 15 | \item{x}{ 16 | Object of class \code{Speclib}. 17 | } 18 | \item{sensor}{ 19 | \code{data.frame} containing definition of sensor characteristics. See details section for further information. 20 | } 21 | } 22 | \details{ 23 | The characteristics must be passed as a \code{data.frame} with two columns: first column with lower bounds of channels and second column with upper bounds. Alternatively, the \code{data.frame} may encompass band centre wavelength and full-width-half-maximum values of the sensor. Function will check the kind of data passed by partially matching the names of the data frame: If any column is named \code{"fwhm"} or \code{"center"}, it is assumed that data are band centre and full-width-half-maximum values. 24 | } 25 | 26 | \author{ 27 | Lukas Lehnert 28 | } 29 | \value{ 30 | Object of class \code{Speclib} containing the updated version of x. 31 | } 32 | \seealso{ 33 | \code{\link{spectralResampling}} 34 | } 35 | 36 | \examples{ 37 | ## Load example data 38 | data(spectral_data) 39 | ## Create sensor featuring 10 times higher spectral resolution 40 | bounds <- seq(min(wavelength(spectral_data)), 41 | max(wavelength(spectral_data)), 42 | length.out = nbands(spectral_data)*10) 43 | sensor <- data.frame(lb = bounds[-1*100 + 1], ub = bounds[-1]) 44 | ## Interpolate first spectrum 45 | inter <- spectralInterpolation(spectral_data[1,], sensor = sensor) 46 | } 47 | \keyword{ utilities } 48 | -------------------------------------------------------------------------------- /man/spectral_data.Rd: -------------------------------------------------------------------------------- 1 | \name{spectral_data} 2 | \alias{spectral_data} 3 | \docType{data} 4 | %- Also NEED an '\alias' for EACH other topic documented here. 5 | \title{ 6 | Hyperspectral samples 7 | } 8 | \description{ 9 | Hyperspectral samples from a FACE experiment in Germany 10 | } 11 | \usage{ 12 | data(spectral_data) 13 | } 14 | \details{ 15 | Data has been sampled during vegetation period 2014 in spring and summer. Measurements were taken with a HandySpec Field portable spectrometer (tec5 AG Oberursel, Germany). This device has two channels measuring incoming and reflected radiation simultaneously between 305 and 1705 nm in 1 nm steps. 16 | } 17 | \format{An object of class \code{Speclib}} 18 | \author{Wolfgang A. Obermeier, Lukas Lehnert, Hanna Meyer} 19 | 20 | \keyword{datasets} 21 | 22 | -------------------------------------------------------------------------------- /man/subset_nri.Rd: -------------------------------------------------------------------------------- 1 | \name{subset.nri} 2 | \alias{subset.nri} 3 | \alias{subset,Nri-method} 4 | %- Also NEED an '\alias' for EACH other topic documented here. 5 | \title{ 6 | Subsetting \code{Nri}-objects 7 | } 8 | \description{ 9 | Return subsets of \code{Nri}-objects which meet conditions. 10 | } 11 | \usage{ 12 | \S4method{subset}{Nri}(x, subset, ...) 13 | } 14 | %- maybe also 'usage' for other objects documented here. 15 | \arguments{ 16 | \item{x}{ 17 | Object of class 'Nri'. 18 | } 19 | \item{subset}{ 20 | Logical expression indicating spectra to keep: missing values are taken as false. See details section. 21 | } 22 | \item{...}{ 23 | Further arguments passed to \code{\link{agrep}}. 24 | } 25 | } 26 | \details{ 27 | Matchable objects are SI data. Use column names to identify the respectrive SI. See \code{\link{SI}} to access SI of a \code{Nri}. IDs of samples may be accessed using "id.nri" as variable name. 28 | } 29 | \value{ 30 | Object of class \code{Nri}. 31 | } 32 | 33 | \author{ 34 | Lukas Lehnert 35 | } 36 | 37 | 38 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 39 | 40 | \seealso{ 41 | \code{\linkS4class{Nri}}, \code{\link{SI}} 42 | } 43 | \examples{ 44 | % \dontrun{ 45 | data(spectral_data) 46 | 47 | ## Calculate all possible combinations for WorldView-2-8 48 | spec_WV <- spectralResampling(spectral_data, "WorldView2-8", 49 | response_function = FALSE) 50 | nri_WV <- nri(spec_WV, recursive = TRUE) 51 | 52 | ## Return names of SI data 53 | names(SI(nri_WV)) 54 | 55 | ## Divide into both seasons 56 | sp_summer <- subset(nri_WV, season == "summer") 57 | sp_spring <- subset(nri_WV, season == "spring") 58 | 59 | ## Print both Nri-objects 60 | sp_summer 61 | sp_spring 62 | 63 | ## Divide into both seasons and years 64 | sp_summer_14 <- subset(nri_WV, season == "summer" & year == 2014) 65 | sp_spring_14 <- subset(nri_WV, season == "spring" & year == 2014) 66 | 67 | ## Print both Nri-objects 68 | sp_summer_14 69 | sp_spring_14 70 | 71 | % } 72 | } 73 | % Add one or more standard keywords, see file 'KEYWORDS' in the 74 | % R documentation directory. 75 | \keyword{utilities} 76 | -------------------------------------------------------------------------------- /man/subset_speclib.Rd: -------------------------------------------------------------------------------- 1 | \name{subset.speclib} 2 | \alias{subset.speclib} 3 | \alias{subset,Speclib-method} 4 | %- Also NEED an '\alias' for EACH other topic documented here. 5 | \title{ 6 | Subsetting speclibs 7 | } 8 | \description{ 9 | Function to return subsets of \code{Speclib}s by defined conditions. 10 | } 11 | \usage{ 12 | \S4method{subset}{Speclib}(x, subset, ...) 13 | } 14 | %- maybe also 'usage' for other objects documented here. 15 | \arguments{ 16 | \item{x}{ 17 | Object of class 'Speclib'. 18 | } 19 | \item{subset}{ 20 | Logical expression indicating spectra to keep: missing values are taken as false. Multiple expressions can be applied using logical operators AND and OR. See details section. 21 | } 22 | \item{...}{ 23 | Further arguments passed to \code{\link{agrep}}. 24 | } 25 | } 26 | \details{ 27 | Matchable objects are SI data. Use column names to identify the respective SI. See \code{\link{SI}} to access SI of a \code{Speclib}. IDs of spectra may be accessed using "id.speclib" as variable name. To subset certain wavelength ranges of a \code{Speclib} refer to \code{\link{mask}}. 28 | } 29 | \value{ 30 | Object of class \code{Speclib}. 31 | } 32 | 33 | \author{ 34 | Lukas Lehnert, Wolfgang Obermeier 35 | } 36 | 37 | 38 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 39 | 40 | \seealso{ 41 | \code{\linkS4class{Speclib}}, \code{\link{SI}}, \code{\link{mask}} 42 | } 43 | \examples{ 44 | % \dontrun{ 45 | 46 | data(spectral_data) 47 | 48 | ## Return names of SI data 49 | names(SI(spectral_data)) 50 | 51 | ## Divide into both seasons 52 | sp_summer <- subset(spectral_data, season == "summer") 53 | sp_spring <- subset(spectral_data, season == "spring") 54 | 55 | ## Divide into both seasons and years 56 | sp_summer_14 <- subset(spectral_data, season == "summer" & year == 2014) 57 | sp_spring_14 <- subset(spectral_data, season == "spring" & year == 2014) 58 | 59 | ## Plot all speclibs 60 | plot(sp_spring_14, col="green", ylim = c(0,80)) 61 | plot(sp_summer_14, col="red", new = FALSE) 62 | 63 | % } 64 | } 65 | % Add one or more standard keywords, see file 'KEYWORDS' in the 66 | % R documentation directory. 67 | \keyword{utilities} 68 | -------------------------------------------------------------------------------- /man/t.test.nri.Rd: -------------------------------------------------------------------------------- 1 | \name{t.test} 2 | \alias{t.test.nri} 3 | \alias{t.test,Nri-method} 4 | % \alias{t.test_nri.formula} 5 | % \alias{print.ttestnri} 6 | \title{ t-test for nri values} 7 | \description{ 8 | Performs Student's t-tests for normalized ratio index values. 9 | } 10 | 11 | \usage{ 12 | \S4method{t.test}{Nri}(x, ...) 13 | 14 | % \method{t.test_nri}{formula}(formula, ...) 15 | %\method{print}{ttestnri}(x, ...) 16 | } 17 | \arguments{ 18 | \item{x}{ 19 | Object of class \code{'nri'}. 20 | } 21 | % \item{formula}{ 22 | % A formula of the form lhs ~ rhs where lhs is object of class 'nri' and rhs is a factor with two levels giving the corresponding groups. Note that the parameter data may be used to specify a data.frame or a speclib containing the grouping factor. 23 | % } 24 | \item{...}{ 25 | Arguments to be passed to \code{\link{t.test}}. 26 | } 27 | } 28 | 29 | \value{ 30 | An object of class "data.frame" 31 | } 32 | \author{ Lukas Lehnert & Hanna Meyer } 33 | \seealso{ 34 | \code{\link{t.test}}, \code{\link{cor.test,Nri-method}}, \code{\linkS4class{Nri}} 35 | } 36 | \examples{ 37 | % \dontrun{ 38 | data(spectral_data) 39 | 40 | 41 | ## Calculate nri-values for WorldView-2-8 42 | spec_WV <- spectralResampling(spectral_data, "WorldView2-8", 43 | response_function = FALSE) 44 | nri_WV <- nri(spec_WV, recursive = TRUE) 45 | 46 | ## Perform t.tests between nri-values of both sites 47 | season <- SI(spec_WV)$season 48 | ttestres <- t.test(x = nri_WV, y = season, alternative = "two.sided") 49 | ttestres 50 | 51 | ## Plot p.values of t.tests 52 | plot(ttestres) 53 | % } 54 | } 55 | -------------------------------------------------------------------------------- /man/usagehistory.Rd: -------------------------------------------------------------------------------- 1 | \name{usagehistory} 2 | \alias{usagehistory} 3 | \alias{usagehistory<-} 4 | 5 | %- Also NEED an '\alias' for EACH other topic documented here. 6 | \title{ 7 | History of usage 8 | } 9 | \description{ 10 | Function to read and write history of usage for \code{Speclibs}. Similar to a log file, the history of usage records processing steps applied to a \code{Speclib}. 11 | } 12 | \usage{ 13 | usagehistory(x) 14 | usagehistory(x) <- value 15 | } 16 | %- maybe also 'usage' for other objects documented here. 17 | \arguments{ 18 | \item{x}{ 19 | Object of class Speclib 20 | } 21 | \item{value}{ 22 | Character string to be added to usagehistory or NULL, if usagehistory should be deleted. 23 | } 24 | } 25 | 26 | \value{ 27 | For \code{usagehistory<-}, the updated object. Otherwise a vector containing the history of usage of \code{Speclib} is returned. 28 | } 29 | 30 | \author{ 31 | Lukas Lehnert 32 | } 33 | 34 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 35 | 36 | \seealso{ 37 | \code{\linkS4class{Speclib}} 38 | } 39 | \examples{ 40 | data(spectral_data) 41 | 42 | ## Return history of usage 43 | usagehistory(spectral_data) 44 | 45 | ## Deleting history of usage 46 | usagehistory(spectral_data) <- NULL 47 | spectral_data 48 | 49 | ## Adding entries 50 | usagehistory(spectral_data) <- "New entry" ## Adding new entry 51 | usagehistory(spectral_data) <- "New entry 2" ## Adding second entry 52 | spectral_data 53 | 54 | } 55 | % Add one or more standard keywords, see file 'KEYWORDS' in the 56 | % R documentation directory. 57 | \keyword{utilities} 58 | -------------------------------------------------------------------------------- /man/wavelength.Rd: -------------------------------------------------------------------------------- 1 | \name{wavelength} 2 | \alias{wavelength} 3 | \alias{wavelength<-} 4 | \alias{wavelength,Speclib-method} 5 | \alias{wavelength<-,Speclib,data.frame-method} 6 | \alias{wavelength<-,Speclib,numeric-method} 7 | \alias{fwhm<-} 8 | \alias{fwhm<-,Speclib,numeric-method} 9 | \alias{fwhm} 10 | \alias{fwhm,Speclib-method} 11 | 12 | \alias{wavelength,HyperSpecRaster-method} 13 | \alias{wavelength<-,HyperSpecRaster,numeric-method} 14 | 15 | %- Also NEED an '\alias' for EACH other topic documented here. 16 | \title{ 17 | Handling wavelength and fwhm 18 | } 19 | \description{ 20 | Methods to access and set wavelength (band center) and full-width-half-max (fwhm) values for class \code{Speclib}. 21 | } 22 | \usage{ 23 | \S4method{wavelength}{Speclib}(object) 24 | 25 | \S4method{wavelength}{Speclib,data.frame}(object) <- value 26 | 27 | \S4method{wavelength}{Speclib,numeric}(object) <- value 28 | 29 | \S4method{fwhm}{Speclib}(object) 30 | 31 | \S4method{fwhm}{Speclib,numeric}(object) <- value 32 | } 33 | \arguments{ 34 | \item{object}{ 35 | Object of class \code{Speclib}. 36 | } 37 | \item{value}{ 38 | Numeric vector or data.frame containing wavelength values. Must always be in nm! 39 | } 40 | } 41 | \details{ 42 | Wavelength (band center) and full-width-half-max (fwhm) values are given for each spectral band. The wavelength is mandatory for creation of \code{Speclib} and is used within the whole functionality of the package (e.g., \code{\link{noiseFiltering}}, \code{\link{spectralResampling}}, \code{\link{vegindex}}, \code{\link{nri}}, \code{\link{plot.Speclib}}, \code{\link{mask}}). 43 | } 44 | \value{ 45 | For \code{wavelength<-} and \code{fwhm<-}, the updated object. Otherwise a numeric vector of the wavelength and fwhm-values in nm is returned. 46 | } 47 | 48 | \author{ 49 | Lukas Lehnert 50 | } 51 | 52 | %% ~Make other sections like Warning with \section{Warning }{....} ~ 53 | 54 | \seealso{ 55 | \code{\linkS4class{Speclib}} 56 | } 57 | \examples{ 58 | data(spectral_data) 59 | 60 | wavelength(spectral_data) 61 | } 62 | % Add one or more standard keywords, see file 'KEYWORDS' in the 63 | % R documentation directory. 64 | \keyword{utilities} 65 | -------------------------------------------------------------------------------- /src/LIDF.f90: -------------------------------------------------------------------------------- 1 | !******************************************************************************** 2 | !* Campbell.f 3 | !* 4 | !* Computation of the leaf angle distribution function value (freq) 5 | !* Ellipsoidal distribution function caracterised by the average leaf 6 | !* inclination angle in degree (ala) 7 | !* Campbell 1986 8 | !* 9 | !******************************************************************************** 10 | 11 | SUBROUTINE campbell(n,ala,freq) 12 | 13 | IMPLICIT NONE 14 | 15 | INTEGER(4) :: i,n 16 | DOUBLE PRECISION :: ala,freq(n),dum 17 | DOUBLE PRECISION :: excent,tl1(n),tl2(n),x1,x2,alpha,alpha2 18 | DOUBLE PRECISION :: tx1(13),tx2(13) 19 | DOUBLE PRECISION :: x12,x22,almx1,almx2,alpx1,alpx2,sum0 20 | DATA tx2 /0, 10, 20, 30, 40, 50, 60, 70, 80, 82, 84, 86, 88/ 21 | DATA tx1 /10, 20, 30, 40, 50, 60, 70, 80, 82, 84, 86, 88, 90/ 22 | 23 | DO i=1,n 24 | tl1(i)=tx1(i)*ATAN(1.)/45. 25 | tl2(i)=tx2(i)*ATAN(1.)/45. 26 | ENDDO 27 | excent=EXP(-1.6184e-5*ala**3+2.1145e-3*ala**2-1.2390e-1*ala+3.2491) 28 | sum0 = 0. 29 | DO i=1,n 30 | x1 = excent/(SQRT(1.+excent**2*TAN(tl1(i))**2)) 31 | x2 = excent/(SQRT(1.+excent**2*TAN(tl2(i))**2)) 32 | IF (excent.eq.1.) THEN 33 | freq(i) = ABS(COS(tl1(i))-COS(tl2(i))) 34 | ELSE 35 | alpha = excent/SQRT(ABS(1.-excent**2)) 36 | alpha2 = alpha**2 37 | x12 = x1**2 38 | x22 = x2**2 39 | IF (excent.gt.1) THEN 40 | alpx1 = SQRT(alpha2+x12) 41 | alpx2 = SQRT(alpha2+x22) 42 | dum = x1*alpx1+alpha2*LOG(x1+alpx1) 43 | freq(i) = ABS(dum-(x2*alpx2+alpha2*LOG(x2+alpx2))) 44 | ELSE 45 | almx1 = SQRT(alpha2-x12) 46 | almx2 = SQRT(alpha2-x22) 47 | dum = x1*almx1+alpha2*ASIN(x1/alpha) 48 | freq(i) = ABS(dum-(x2*almx2+alpha2*ASIN(x2/alpha))) 49 | ENDIF 50 | ENDIF 51 | sum0 = sum0+freq(i) 52 | ENDDO 53 | DO i=1,n 54 | freq(i)=freq(i)/sum0 !*100. 55 | ENDDO 56 | 57 | RETURN 58 | END SUBROUTINE 59 | 60 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 61 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 62 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 63 | 64 | SUBROUTINE calc_LIDF_ellipsoidal(na,alpha,freqvar) 65 | IMPLICIT NONE 66 | 67 | INTEGER(4) :: na,ia,icou,k 68 | DOUBLE PRECISION :: opt,bemu,benu,alphadeg,alpha,freqvar(na),freq(na),pi 69 | !............................................................................... 70 | ! Call leaf angle distribution fonction 71 | !............................................................................... 72 | 73 | alphadeg=alpha 74 | 75 | CALL campbell(na,alphadeg,freq) 76 | DO ia=1,na 77 | freqvar(ia)=freq(ia) 78 | ENDDO 79 | 80 | RETURN 81 | END SUBROUTINE 82 | -------------------------------------------------------------------------------- /src/MODULE_PRO4SAIL.f90: -------------------------------------------------------------------------------- 1 | MODULE MOD_ANGLE 2 | DOUBLE PRECISION,SAVE :: pi,rd 3 | END MODULE 4 | 5 | !********************* 6 | 7 | MODULE MOD_staticvar 8 | DOUBLE PRECISION,SAVE :: cts,cto,ctscto 9 | DOUBLE PRECISION,SAVE :: ddb,ddf,dob,dof,dso 10 | DOUBLE PRECISION,SAVE :: ko,ks,sdb,sdf 11 | DOUBLE PRECISION,SAVE :: sob,sof,sumint 12 | DOUBLE PRECISION,ALLOCATABLE,SAVE :: sb(:),sf(:),vb(:),vf(:),w(:) 13 | DOUBLE PRECISION,ALLOCATABLE,SAVE :: m(:),m2(:),att(:),sigb(:),rinf(:),lidf(:) 14 | END MODULE 15 | 16 | !********************* 17 | 18 | MODULE MOD_output_PROSPECT 19 | DOUBLE PRECISION,ALLOCATABLE,SAVE :: LRT(:,:),rho(:),tau(:) 20 | END MODULE 21 | 22 | !********************* 23 | 24 | MODULE MOD_flag_util 25 | LOGICAL flag(7),init_completed,init_completed0 26 | LOGICAL delta_geom,delta_lai,delta_hot,delta_leaf,delta_skyl,delta_soil,delta_lidf 27 | DOUBLE PRECISION,ALLOCATABLE,SAVE :: lidf_old(:),rsoil_old(:) 28 | DOUBLE PRECISION,SAVE :: N_old,Cab_old,Car_old,Cbrown_old,Cw_old,Cm_old 29 | DOUBLE PRECISION,SAVE :: LIDFa_old,LIDFb_old,lai_old,q_old,skyl_old 30 | DOUBLE PRECISION,SAVE :: tts_old,tto_old,psi_old 31 | END MODULE 32 | 33 | !********************* 34 | 35 | MODULE MOD_SAIL 36 | DOUBLE PRECISION,SAVE :: tss,too,tsstoo 37 | DOUBLE PRECISION,ALLOCATABLE,SAVE :: tso(:),tsd(:),tdd(:),tdo(:),rsd(:),rdd(:),rso(:),rdo(:) 38 | DOUBLE PRECISION,ALLOCATABLE,SAVE :: rsos(:),rsod(:),rddt(:),rsdt(:),rdot(:),rsodt(:),rsost(:),rsot(:) 39 | END MODULE 40 | 41 | !********************* -------------------------------------------------------------------------------- /src/Makevars: -------------------------------------------------------------------------------- 1 | all: $(SHLIB) 2 | 3 | main_PROSAIL.o: PRO4SAIL.o MODULE_PRO4SAIL.o dataSpec_P5B_PROSAIL.o 4 | 5 | main_PROSPECT_5B.o: dataSpec_P5B_PROSPECT.o 6 | 7 | main_PROSPECT_D.o: dataSpec_PDB_PROSPECT.o 8 | 9 | PRO4SAIL.o: MODULE_PRO4SAIL.o dataSpec_P5B_PROSAIL.o 10 | 11 | prospect_5B.o: dataSpec_P5B_PROSPECT.o 12 | 13 | prospect_DB.o: dataSpec_PDB_PROSPECT.o 14 | 15 | volscatt.o: MODULE_PRO4SAIL.o 16 | 17 | tav_abs_PROSPECT_5B.o: dataSpec_P5B_PROSPECT.o 18 | 19 | tav_abs_PROSPECT_D.o: dataSpec_PDB_PROSPECT.o 20 | 21 | clean: 22 | rm *.o *.mod *.so 23 | -------------------------------------------------------------------------------- /src/Makevars.win: -------------------------------------------------------------------------------- 1 | PKG_LIBS = $(BLAS_LIBS) 2 | 3 | all: $(SHLIB) 4 | 5 | main_PROSAIL.o: PRO4SAIL.o MODULE_PRO4SAIL.o dataSpec_P5B_PROSAIL.o 6 | 7 | main_PROSPECT_5B.o: dataSpec_P5B_PROSPECT.o 8 | 9 | main_PROSPECT_D.o: dataSpec_PDB_PROSPECT.o 10 | 11 | PRO4SAIL.o: MODULE_PRO4SAIL.o dataSpec_P5B_PROSAIL.o 12 | 13 | prospect_5B.o: dataSpec_P5B_PROSPECT.o 14 | 15 | prospect_DB.o: dataSpec_PDB_PROSPECT.o 16 | 17 | volscatt.o: MODULE_PRO4SAIL.o 18 | 19 | tav_abs_PROSPECT_5B.o: dataSpec_P5B_PROSPECT.o 20 | 21 | tav_abs_PROSPECT_D.o: dataSpec_PDB_PROSPECT.o 22 | 23 | clean: 24 | rm *.o *.mod *.dll 25 | -------------------------------------------------------------------------------- /src/PRO4SAIL.f90: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/src/PRO4SAIL.f90 -------------------------------------------------------------------------------- /src/adminparallel.f90: -------------------------------------------------------------------------------- 1 | subroutine adminparallel (flag, process) 2 | implicit none 3 | integer :: flag, process 4 | integer, save :: process_backup 5 | 6 | if (flag .eq. 0) then 7 | process_backup = -1 8 | elseif (flag .eq. 1) then 9 | process = process_backup 10 | if (process_backup .eq. -1) then 11 | process_backup = 1 12 | endif 13 | endif 14 | 15 | return 16 | end subroutine -------------------------------------------------------------------------------- /src/bandDepthRatioIndices.f90: -------------------------------------------------------------------------------- 1 | subroutine bdr (n, ny, lenval, y) 2 | implicit none 3 | integer, intent(in) :: n ! Number of spectra 4 | integer, intent(in) :: ny 5 | integer, intent(in) :: lenval(n) ! Length of features in spectra 6 | double precision :: y(ny) ! Reflectance values 7 | 8 | integer(4) i, k, m 9 | double precision maxy 10 | 11 | k=1 12 | do i=1, n 13 | maxy = y(k) 14 | do m=k+1, k+lenval(i)-1 15 | if (maxy .lt. y(m)) maxy = y(m) 16 | enddo 17 | do m=k, k+lenval(i) 18 | y(m) = y(m) / maxy 19 | enddo 20 | k = k + 1 + lenval(i) 21 | enddo 22 | return 23 | end subroutine bdr 24 | 25 | subroutine ndbi (n, ny, lenval, y) 26 | implicit none 27 | integer, intent(in) :: n ! Number of spectra 28 | integer, intent(in) :: ny 29 | integer, intent(in) :: lenval(n) ! Length of features in spectra 30 | double precision :: y(ny) ! Reflectance values 31 | 32 | integer(4) i, k, m 33 | double precision maxy 34 | 35 | k=1 36 | do i=1, n 37 | maxy = y(k) 38 | do m=k+1, k+lenval(i)-1 39 | if (maxy .lt. y(m)) maxy = y(m) 40 | enddo 41 | do m=k, k+lenval(i) 42 | y(m) = (y(m) - maxy) / (y(m) + maxy) 43 | enddo 44 | k = k + 1 + lenval(i) 45 | enddo 46 | return 47 | end subroutine ndbi 48 | 49 | subroutine bna (n, ny, lenval, y) 50 | implicit none 51 | integer, intent(in) :: n ! Number of spectra 52 | integer, intent(in) :: ny 53 | integer, intent(in) :: lenval(n) ! Length of features in spectra 54 | double precision :: y(ny) ! Reflectance values 55 | 56 | integer(4) i, k, m 57 | double precision area 58 | 59 | k=1 60 | do i=1, n 61 | area = 0.0 62 | do m=k, k+lenval(i)-1 63 | area = area + y(m) 64 | enddo 65 | do m=k, k+lenval(i) 66 | y(m) = y(m) / area 67 | enddo 68 | k = k + 1 + lenval(i) 69 | enddo 70 | return 71 | end subroutine bna 72 | -------------------------------------------------------------------------------- /src/c2lablas.f: -------------------------------------------------------------------------------- 1 | ! y := alpha*A*x + beta*y 2 | SUBROUTINE c2dgemv (M, N, AM, X, Y) 3 | IMPLICIT NONE 4 | 5 | INTEGER, intent(in) :: M, N 6 | ! * .. 7 | ! * .. Array Arguments .. 8 | DOUBLE PRECISION, intent(in) :: X(N), AM(M,N) 9 | DOUBLE PRECISION, intent(out) :: Y(M) 10 | 11 | DOUBLE PRECISION ALPHA, BETA 12 | CHARACTER(1) TRANS 13 | 14 | 15 | ALPHA = 1.0D+0 16 | BETA = 0.0D+0 17 | 18 | ! call intpr("M", 1, M, 1) 19 | ! call intpr("N", 1, N, 1) 20 | 21 | TRANS = 'N' 22 | 23 | 24 | CALL DGEMV(TRANS,M,N,ALPHA,AM,M,X,1,BETA,Y,1) 25 | 26 | END SUBROUTINE 27 | 28 | -------------------------------------------------------------------------------- /src/c2lablas.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef C2LABLAS_H 3 | #define C2LABLAS_H 4 | 5 | #include 6 | #include 7 | 8 | extern void F77_NAME(c2dgemv)(int *M, int *N, double *AM, double *X, double *Y); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/checkhull.f90: -------------------------------------------------------------------------------- 1 | subroutine checkhull (ncp, n, pts, y, offset, res, hull) 2 | integer, intent(in) :: ncp ! Number of continuum points 3 | integer, intent(in) :: n ! Length of spectra 4 | integer, intent(in) :: pts(ncp) ! Continuum points 5 | double precision, intent(in) :: y(n) ! Reflectance values 6 | integer, intent(in) :: offset 7 | integer, intent(out) :: res(2) ! Flag if hull matches data 8 | double precision, intent(out) :: hull(n) ! Hull values 9 | 10 | integer :: maxreswavelength 11 | 12 | integer :: i, k, ptscon(ncp) 13 | double precision :: slope, intercept, gmval, tol 14 | 15 | res=0 16 | tol=-1.0e-7 17 | hull=0.0 18 | 19 | ptscon = pts-offset 20 | 21 | hull(ptscon(1))=y(ptscon(1)) 22 | 23 | do i=2, ncp 24 | slope = (y(ptscon(i))-y(ptscon(i-1)))/dble(ptscon(i)-ptscon(i-1)) 25 | intercept = y(ptscon(i-1))-slope*dble(ptscon(i-1)) 26 | 27 | hull(ptscon(i)) = dble(ptscon(i))*slope+intercept 28 | do k=ptscon(i-1)+1, ptscon(i)-1 29 | gmval = dble(k)*slope+intercept 30 | hull(k) = gmval 31 | if ((gmval-y(k)).lt.tol) then 32 | res(1)=k+offset 33 | res(2)=maxreswavelength(ptscon(i-1),ptscon(i),y(ptscon(i-1):ptscon(i)),& 34 | slope,intercept) + offset 35 | return 36 | endif 37 | enddo 38 | enddo 39 | 40 | end subroutine checkhull 41 | 42 | subroutine makehull (ncp, n, pts, y, offset, hull) 43 | implicit none 44 | integer, intent(in) :: ncp ! Number of continuum points 45 | integer, intent(in) :: n ! Length of spectra 46 | integer, intent(in) :: pts(ncp) ! Continuum points 47 | double precision, intent(in) :: y(n) ! Reflectance values 48 | integer, intent(in) :: offset 49 | double precision, intent(out) :: hull(n) ! Hull values 50 | 51 | integer :: i, k, ptscon(ncp) 52 | double precision :: slope, intercept 53 | 54 | hull=0.0 55 | 56 | ptscon = pts-offset 57 | 58 | hull(ptscon(1))=y(ptscon(1)) 59 | 60 | do i=2, ncp 61 | slope = (y(ptscon(i))-y(ptscon(i-1)))/dble(ptscon(i)-ptscon(i-1)) 62 | intercept = y(ptscon(i-1))-slope*dble(ptscon(i-1)) 63 | 64 | hull(ptscon(i)) = dble(ptscon(i))*slope+intercept 65 | do k=ptscon(i-1)+1, ptscon(i)-1 66 | hull(k) = dble(k)*slope+intercept 67 | enddo 68 | enddo 69 | 70 | end subroutine makehull 71 | 72 | integer function maxreswavelength(startval,stopval,y,slope,intercept) 73 | implicit none 74 | integer :: startval, stopval, i, mv 75 | double precision :: slope, intercept, diff, gmval 76 | double precision :: y(stopval-startval+1) 77 | 78 | diff = 0.0 79 | mv = 0 80 | 81 | do i=1,stopval-startval+1 82 | gmval = dble(i+startval-1)*slope+intercept 83 | if ((y(i)-gmval).gt.diff) then 84 | diff = y(i)-gmval 85 | mv = i+startval-1 86 | endif 87 | enddo 88 | 89 | maxreswavelength = mv 90 | 91 | return 92 | end function maxreswavelength -------------------------------------------------------------------------------- /src/dataSpec_P5B_PROSAIL.f90: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/src/dataSpec_P5B_PROSAIL.f90 -------------------------------------------------------------------------------- /src/dataSpec_P5B_PROSPECT.f90: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/src/dataSpec_P5B_PROSPECT.f90 -------------------------------------------------------------------------------- /src/dataSpec_PDB_PROSPECT.f90: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/src/dataSpec_PDB_PROSPECT.f90 -------------------------------------------------------------------------------- /src/differenciate.f90: -------------------------------------------------------------------------------- 1 | subroutine differenciate (nwl,n,m,y,bandcenter,derivation) 2 | implicit none 3 | integer, intent(in) :: nwl ! Number of bands 4 | integer, intent(in) :: n ! Number of spectra 5 | integer, intent(in) :: m ! m th derivation 6 | double precision, intent(in) :: y(n,nwl) ! Reflectance value 7 | double precision, intent(in) :: bandcenter(nwl) ! Width of bands 8 | double precision, intent(out) :: derivation(n,nwl) ! Derivation 9 | 10 | integer i, k, l 11 | 12 | derivation = y 13 | 14 | do i=1, n 15 | do l=1, m 16 | do k=1, nwl-l 17 | derivation(i,k) = (derivation(i,k+1)-derivation(i,k))/ & 18 | (bandcenter(k+1)-bandcenter(k)) 19 | enddo 20 | do k=nwl-l, nwl 21 | derivation(i,k) = 0.0 22 | enddo 23 | enddo 24 | enddo 25 | return 26 | end subroutine -------------------------------------------------------------------------------- /src/dladgen.f: -------------------------------------------------------------------------------- 1 | subroutine dladgen(a,b,freq) 2 | c 3 | DOUBLE PRECISION a,b,freq(13),t 4 | DOUBLE PRECISION dcum 5 | c 6 | do i1=1,8 7 | t=i1*10. 8 | freq(i1)=dcum(a,b,t) 9 | end do 10 | c 11 | do i2=9,12 12 | t=80.+(i2-8)*2. 13 | freq(i2)=dcum(a,b,t) 14 | end do 15 | c 16 | freq(13)=1. 17 | c 18 | do i=13,2,-1 19 | freq(i)=freq(i)-freq(i-1) 20 | end do 21 | c 22 | return 23 | end 24 | 25 | 26 | function dcum(a,b,t) 27 | c 28 | DOUBLE PRECISION a,b,t,pi,rd,eps,delx,p,y,x,dx,dcum 29 | pi=atan(1.)*4. 30 | rd=pi/180. 31 | 32 | if (a.gt.1.) then 33 | c 34 | dcum=1.-cos(rd*t) 35 | c 36 | else 37 | 38 | eps=1.e-8 39 | delx=1. 40 | c 41 | x=2*rd*t 42 | p=x 43 | c 44 | do while (delx.gt.eps) 45 | y = a*sin(x)+.5*b*sin(2.*x) 46 | dx=.5*(y-x+p) 47 | x=x+dx 48 | delx=abs(dx) 49 | end do 50 | c 51 | dcum=(2.*y+p)/pi 52 | c 53 | endif 54 | c 55 | return 56 | end 57 | -------------------------------------------------------------------------------- /src/interpolate.f90: -------------------------------------------------------------------------------- 1 | ! code <- " 2 | subroutine inter(b1, n_b1, b2, n_b2, refl_in, refl_out, nspectra) 3 | implicit none 4 | integer n_b1, n_b2, nspectra 5 | integer indices(n_b2, 2) 6 | double precision b1(n_b1), b2(n_b2), refl_in(nspectra, n_b1), refl_out(nspectra, n_b2) 7 | double precision weights(n_b2) 8 | 9 | integer i, k 10 | ! double precision tol 11 | 12 | ! tol = 1.0e-10 13 | 14 | indices = 0 15 | do i=1, n_b2 16 | k = 2 17 | do while ((k .le. n_b1) .and. (indices(i, 1)*indices(i, 2)) .eq. 0) 18 | if (indices(i, 1) .eq. 0) then 19 | if (b2(i) .ge. b1(k-1) .and. b2(i) .le. b1(k)) then 20 | indices(i, 1) = k-1 21 | endif 22 | endif 23 | 24 | if (indices(i, 2) .eq. 0) then 25 | if (b2(i) .le. b1(k) .and. b2(i) .gt. b1(k-1)) then 26 | indices(i, 2) = k 27 | endif 28 | endif 29 | k = k + 1 30 | enddo 31 | enddo 32 | 33 | 34 | do i=1, n_b2 35 | weights(i) = (b2(i) - b1(indices(i,1)))/(b1(indices(i,2))-b1(indices(i,1))) 36 | enddo 37 | 38 | ! do i = 1, 5 39 | ! print*, refl_in(1, i) 40 | ! enddo 41 | ! do i = 1, 5 42 | ! print*, refl_in(i, 1) 43 | ! enddo 44 | 45 | do i = 1, n_b2 46 | refl_out(:,i) = (1.0 - weights(i)) * refl_in(:, indices(i,1)) + weights(i) * refl_in(:, indices(i,2)) 47 | enddo 48 | 49 | return 50 | 51 | end subroutine 52 | ! " 53 | -------------------------------------------------------------------------------- /src/localMaxima.f90: -------------------------------------------------------------------------------- 1 | subroutine localmaxima (n, y, locmax) 2 | implicit none 3 | integer, intent(in) :: n ! Length of spectra 4 | real, intent(in) :: y(n) ! Reflectance value 5 | integer, intent(out) :: locmax(n) ! Index of Local Maxima 6 | 7 | integer :: i 8 | 9 | locmax(1)=1 10 | locmax(n)=n 11 | do i=2, n-1 12 | if (y(i).gt.y(i-1) .and. y(i).gt.y(i+1)) then 13 | locmax(i)=i 14 | endif 15 | enddo 16 | end subroutine localmaxima 17 | -------------------------------------------------------------------------------- /src/main_PROSAIL.f90: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/src/main_PROSAIL.f90 -------------------------------------------------------------------------------- /src/main_PROSPECT_5B.f90: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/src/main_PROSPECT_5B.f90 -------------------------------------------------------------------------------- /src/main_PROSPECT_D.f90: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/src/main_PROSPECT_D.f90 -------------------------------------------------------------------------------- /src/meanfilter.f90: -------------------------------------------------------------------------------- 1 | subroutine meanfilter (nwl,n,p,y,smoothedy) 2 | implicit none 3 | integer, intent(in) :: nwl ! Number of bands 4 | integer, intent(in) :: n ! Number of spectra 5 | integer, intent(in) :: p ! Window size 6 | double precision, intent(in) :: y(n,nwl) ! Reflectance values 7 | double precision, intent(out) :: smoothedy(n,nwl) ! Smoothed reflectance values 8 | 9 | integer :: i, k, l, stop_index, start_index 10 | double precision :: su 11 | 12 | do i=1, n 13 | do k=1, nwl 14 | start_index = max(1, k-p) 15 | stop_index = min(nwl, k+p) 16 | 17 | su = 0.0 18 | 19 | do l=start_index, stop_index 20 | su = su + y(i,l) 21 | enddo 22 | 23 | smoothedy(i, k) = su/dble(stop_index-start_index+1) 24 | 25 | enddo 26 | 27 | enddo 28 | 29 | 30 | return 31 | end subroutine meanfilter 32 | 33 | subroutine gliding_meanfilter (nwl,n,p,y,smoothedy) 34 | implicit none 35 | integer, intent(in) :: nwl ! Number of bands 36 | integer, intent(in) :: n ! Number of spectra 37 | integer, intent(in) :: p ! Window size 38 | double precision, intent(in) :: y(n,nwl) ! Reflectance values 39 | double precision, intent(out) :: smoothedy(n,nwl) ! Smoothed reflectance values 40 | 41 | integer :: i, k, l 42 | double precision :: su 43 | 44 | do i=1, n 45 | do k=1, p-1 46 | su = 0.0 47 | do l=1, k 48 | su = su + y(i,l) 49 | enddo 50 | smoothedy(i,k) = su / dble(k) 51 | enddo 52 | do k=p, nwl 53 | su = 0.0 54 | do l=k-p+1, k 55 | su = su + y(i,l) 56 | enddo 57 | smoothedy(i,k) = su / dble(p) 58 | enddo 59 | enddo 60 | return 61 | end subroutine gliding_meanfilter 62 | ! 63 | ! subroutine savitzky_golay (nwl,n,p,y,smoothedy) 64 | ! implicit none 65 | ! integer, intent(in) :: nwl ! Number of bands 66 | ! integer, intent(in) :: n ! Number of spectra 67 | ! integer, intent(in) :: p ! Window size 68 | ! double precision, intent(in) :: y(n,nwl) ! Reflectance values 69 | ! double precision, intent(out) :: smoothedy(n,nwl) ! Smoothed reflectance values 70 | ! 71 | ! do i=1, n 72 | ! do k=1, p 73 | ! smoothedy(i, k) = y(i, k) 74 | ! enddo 75 | ! 76 | ! do k=p+1, nwl-p-1 77 | ! start_index = k-p 78 | ! stop_index = k+p 79 | ! 80 | ! su = 0.0 81 | ! 82 | ! do l=start_index, stop_index 83 | ! su = su + y(i,l) 84 | ! enddo 85 | ! 86 | ! smoothedy(i, k) = su/dble(stop_index-start_index+1) 87 | ! 88 | ! enddo 89 | ! 90 | ! do k=nwl-p, nwl 91 | ! smoothedy(i, k) = y(i, k) 92 | ! enddo 93 | ! 94 | ! enddo 95 | ! 96 | ! 97 | ! return 98 | ! end subroutine savitzky_golay -------------------------------------------------------------------------------- /src/prospect_5B.f90: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/src/prospect_5B.f90 -------------------------------------------------------------------------------- /src/prospect_DB.f90: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/src/prospect_DB.f90 -------------------------------------------------------------------------------- /src/pt2f.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | double F77_SUB(pt2f)(double* xx, double* nn) 5 | { 6 | double x ; 7 | double n ; 8 | n = nn[0]; 9 | x = xx[0]; 10 | 11 | return pt(x, n, 0, 0); 12 | } 13 | -------------------------------------------------------------------------------- /src/recursiveNRI.f90: -------------------------------------------------------------------------------- 1 | subroutine recursive_nri (nwl, nspec, reflectance, nri, nri_length) 2 | implicit none 3 | integer, intent(in) :: nwl ! Number of bands in data 4 | integer, intent(in) :: nspec ! Number of spectra 5 | integer, intent(in) :: nri_length 6 | real, intent(in) :: reflectance(nspec,nwl) ! Reflectance values 7 | real, intent(out) :: nri(nri_length) ! Normalized ratio index values 8 | 9 | integer i, k, m 10 | integer(8) n 11 | 12 | nri = 0.0 13 | n = 0 14 | do m=1, nspec 15 | do i=1, nwl-1 16 | do k=i+1, nwl 17 | n = n + 1 18 | nri(n) = (reflectance(m,k)-reflectance(m,i)) / & 19 | (reflectance(m,k)+reflectance(m,i)) 20 | enddo 21 | enddo 22 | enddo 23 | end subroutine recursive_nri 24 | 25 | -------------------------------------------------------------------------------- /src/recursiveSR.f90: -------------------------------------------------------------------------------- 1 | subroutine recursive_sr (nwl, nspec, reflectance, sr, sr_length) 2 | implicit none 3 | integer, intent(in) :: nwl ! Number of bands in data 4 | integer, intent(in) :: nspec ! Number of spectra 5 | integer, intent(in) :: sr_length 6 | real, intent(in) :: reflectance(nspec,nwl) ! Reflectance values 7 | real, intent(out) :: sr(sr_length) ! Normalized ratio index values 8 | 9 | integer i, k, m, n 10 | 11 | sr = 0.0 12 | n = 0 13 | do m=1, nspec 14 | do i=1, nwl-1 15 | do k=i+1, nwl 16 | n = n + 1 17 | sr(n) = (reflectance(m,k)/reflectance(m,i)) 18 | enddo 19 | enddo 20 | enddo 21 | end subroutine recursive_sr 22 | -------------------------------------------------------------------------------- /src/registerDynamicSymbol.c: -------------------------------------------------------------------------------- 1 | // RegisteringDynamic Symbols 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void R_init_markovchain(DllInfo* info) { 8 | R_registerRoutines(info, NULL, NULL, NULL, NULL); 9 | R_useDynamicSymbols(info, TRUE); 10 | } 11 | -------------------------------------------------------------------------------- /src/sam.f90: -------------------------------------------------------------------------------- 1 | subroutine sam (nspec, nref, nbands, spec, specref, specang) 2 | implicit none 3 | integer, intent(in) :: nspec 4 | integer, intent(in) :: nref 5 | integer, intent(in) :: nbands 6 | double precision, intent(in) :: spec(nspec,nbands) 7 | double precision, intent(in) :: specref(nref,nbands) 8 | double precision, intent(out) :: specang(nspec,nref) 9 | 10 | 11 | integer ispec, iband, iref 12 | double precision ssspec, ssref, ssboth 13 | 14 | 15 | do ispec=1, nspec 16 | do iref=1, nref 17 | ssspec = 0.0 18 | ssref = 0.0 19 | ssboth = 0.0 20 | do iband=1, nbands 21 | ssspec = ssspec + spec(ispec,iband)**2 22 | ssref = ssref + specref(iref,iband)**2 23 | ssboth = ssboth + spec(ispec,iband) * & 24 | specref(iref,iband) 25 | enddo 26 | 27 | specang(ispec,iref) = dble(acos(ssboth/(ssspec**0.5 * ssref**0.5))) 28 | 29 | enddo 30 | enddo 31 | 32 | end subroutine sam 33 | -------------------------------------------------------------------------------- /src/tav_abs_PROSPECT_5B.f90: -------------------------------------------------------------------------------- 1 | ! ******************************************************************************** 2 | ! tav_abs.f90 3 | ! ******************************************************************************** 4 | ! computation of the average transmittivity at the leaf surface within a given 5 | ! solid angle. teta is the incidence solid angle (in radian). The average angle 6 | ! that works in most cases is 40deg*pi/180. ref is the refaction index. 7 | ! ******************************************************************************** 8 | ! Stern F. (1964), Transmission of isotropic radiation across an interface between 9 | ! two dielectrics, Applied Optics, 3:111-113. 10 | ! Allen W.A. (1973), Transmission of isotropic light across a dielectric surface in 11 | ! two and three dimensions, Journal of the Optical Society of America, 63:664-666. 12 | ! ******************************************************************************** 13 | ! version 5.02 (25 July 2011) 14 | ! ******************************************************************************** 15 | 16 | subroutine tav_abs(theta,refr,res) 17 | 18 | use dataSpec_P5B 19 | implicit none 20 | 21 | double precision, intent(in) :: theta, refr(nw) 22 | double precision, intent(out) :: res(nw) 23 | 24 | double precision pi, thetarad 25 | double precision refr2(nw) 26 | double precision ax(nw),bx(nw),b0(nw),b1(nw),b2(nw) 27 | double precision ts(nw),tp(nw),tp1(nw),tp2(nw),tp3(nw),tp4(nw),tp5(nw) 28 | 29 | pi=atan(1.)*4. 30 | thetarad=pi*theta/180. 31 | 32 | if (theta.eq.0.) then 33 | res=4.*refr/(refr+1.)**2 34 | return 35 | endif 36 | 37 | refr2=refr*refr 38 | ax=(refr+1.)**2/2. 39 | bx=-(refr2-1.)**2/4. 40 | 41 | if (thetarad.eq.pi/2.) then 42 | b1=0. 43 | else 44 | b1=dsqrt((sin(thetarad)**2-(refr2+1.)/2.)**2+bx) 45 | endif 46 | b2=sin(thetarad)**2-(refr2+1.)/2. 47 | b0=b1-b2 48 | ts=(bx**2/(6.*b0**3)+bx/b0-b0/2.)-(bx**2/(6.*ax**3)+bx/ax-ax/2.) 49 | tp1=-2.*refr2*(b0-ax)/(refr2+1.)**2 50 | tp2=-2.*refr2*(refr2+1.)*dlog(b0/ax)/(refr2-1.)**2 51 | tp3=refr2*(1./b0-1./ax)/2. 52 | tp4=16.*refr2**2*(refr2**2+1.)*dlog((2.*(refr2+1.)*b0-(refr2-1.)**2)/ & 53 | (2.*(refr2+1.)*ax-(refr2-1.)**2))/((refr2+1.)**3*(refr2-1.)**2) 54 | tp5=16.*refr2**3*(1./(2.*(refr2+1.)*b0-((refr2-1.)**2))-1./(2.*(refr2+1.) & 55 | *ax-(refr2-1.)**2))/(refr2+1.)**3 56 | tp=tp1+tp2+tp3+tp4+tp5 57 | res=(ts+tp)/(2.*sin(thetarad)**2) 58 | 59 | return 60 | end 61 | -------------------------------------------------------------------------------- /src/tav_abs_PROSPECT_D.f90: -------------------------------------------------------------------------------- 1 | ! ******************************************************************************** 2 | ! tav_abs.f90 3 | ! ******************************************************************************** 4 | ! computation of the average transmittivity at the leaf surface within a given 5 | ! solid angle. teta is the incidence solid angle (in radian). The average angle 6 | ! that works in most cases is 40deg*pi/180. ref is the refaction index. 7 | ! ******************************************************************************** 8 | ! Stern F. (1964), Transmission of isotropic radiation across an interface between 9 | ! two dielectrics, Applied Optics, 3:111-113. 10 | ! Allen W.A. (1973), Transmission of isotropic light across a dielectric surface in 11 | ! two and three dimensions, Journal of the Optical Society of America, 63:664-666. 12 | ! ******************************************************************************** 13 | ! version 5.02 (25 July 2011) 14 | ! ******************************************************************************** 15 | 16 | subroutine tav_abs_D(theta,nr,tav) 17 | 18 | use dataSpec_PDB 19 | implicit none 20 | 21 | real(8), intent(in) :: theta, nr(nw) 22 | real(8), intent(out) :: tav(nw) 23 | 24 | real(8) pi,rd 25 | real(8) n2(nw),np(nw),nm(nw) 26 | real(8) a(nw),k(nw),sa(nw),b1(nw),b2(nw),b3(nw),b(nw),a3(nw) 27 | real(8) ts(nw),tp(nw),tp1(nw),tp2(nw),tp3(nw),tp4(nw),tp5(nw) 28 | 29 | 30 | pi = atan(1.)*4. 31 | rd = pi/180. 32 | n2 = nr**2. 33 | np = n2+1. 34 | nm = n2-1. 35 | a = (nr+1)*(nr+1.)/2. 36 | k = -(n2-1)*(n2-1.)/4. 37 | sa = sin(theta*rd) 38 | 39 | if (theta.eq.90.) then 40 | b1=0. 41 | else 42 | b1 = dsqrt((sa**2-np/2)*(sa**2-np/2)+k) 43 | endif 44 | 45 | b2 = sa**2-np/2 46 | b = b1-b2 47 | b3 = b**3 48 | a3 = a**3 49 | ts = (k**2./(6*b3)+k/b-b/2)-(k**2./(6*a3)+k/a-a/2) 50 | 51 | tp1 = -2*n2*(b-a)/(np**2) 52 | tp2 = -2*n2*np*dlog(b/a)/(nm**2) 53 | tp3 = n2*(1./b-1./a)/2 54 | tp4 = 16*n2**2.*(n2**2+1)*dlog((2*np*b-nm**2)/(2*np*a-nm**2))/(np**3.*nm**2) 55 | tp5 = 16*n2**3.*(1./(2*np*b-nm**2)-1./(2*np*a-nm**2))/(np**3) 56 | tp = tp1+tp2+tp3+tp4+tp5 57 | tav = (ts+tp)/(2*sa**2) 58 | 59 | return 60 | end 61 | -------------------------------------------------------------------------------- /vignettes/References.Rnw: -------------------------------------------------------------------------------- 1 | %\VignetteIndexEntry{References of hyperspectral indices} 2 | 3 | \documentclass{article} 4 | \usepackage[ansinew]{inputenc} 5 | 6 | \usepackage{natbib} 7 | % 8 | %opening 9 | \title{References for package ``hsdar''} 10 | \author{Lukas W.~Lehnert} 11 | 12 | \begin{document} 13 | 14 | \maketitle 15 | \nocite{Wu2014d,Galvao2005,Apan2004,Levin2007,Lobell2001,Mathieu1998,Madeira1997} 16 | \nocite{Hunt2013,Mutanga2004b,Tsai1998,Kruse1993,Thenkabail2000,Jacquemoud2009,Jacquemoud1990a,Clark1987,Mutanga2004c,Sohn1997,Bach1995} 17 | \nocite{Merzlyak1999, Garrity2011, Blackburn1998a, Hernandez-Clemente2011,Hernandez-Clemente2012a,Oppelt2004} 18 | \nocite{Penuelas1997,Penuelas1995a,Hunt1989,Guyot1988,Nagler2003,Huete1988a,Vincini2006,Broge2001,Gao1996,Gamon1992} 19 | \nocite{Boochs1990,Carter1994,CHAPPELLE1992,Chen1996,Dash2004,Datt1999,Datt1998,Daughtry2000,ELVIDGE1995,FILELLA1994,Gandia2004,Gitelson1996,Gitelson1997,Gitelson1999,Gitelson1994,Gitelson2003,Gitelson2003,Haboudane2002,Haboudane2002,Huete1997,JORDAN1969,Kim1994,Lichtenthaler1996,Maccioni2001,Maire2004,Maire2008,MCMURTREY1994,Penuelas1995,Penuelas1994,Qi1994,Rondeaux1996,ROUJEAN1995,ROUJEAN1995,Sims2002,Smith1995,TUCKER1979,VOGELMANN1993,Wu2008,Zarco-Tejada2003b,Zarco-Tejada1999,Serrano2002,Zarco-Tejada2013} 20 | \nocite{Datt1999a,Haubrock2008,Ben-Dor2006,Whiting2004,McNairn1993,Escadafal1994,Escadafal1991} 21 | 22 | \bibliography{hsdar}\bibliographystyle{elsarticle-harv} 23 | 24 | 25 | \end{document} 26 | -------------------------------------------------------------------------------- /vignettes/hsdar.bib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/hsdar/3c5cd851e3dd181b361b23b494d05dbeb02c2018/vignettes/hsdar.bib --------------------------------------------------------------------------------