I have four spectral libraries, one of which contains mixed spectra of vegetation (350-2500 nm) and three of which contain the pure spectra of the endmembers of the mixed spectra. I’m trying to find out how to perform Multiple Endmember Spectral Mixing Analysis (MESMA) to find out the cover fractions of each endmember, and currently I’m using non-negative least squares fitting,
r-package nnls
. However, this does not seem to be good/robust way to do it: my desired output is that the fractions sum up to 1, which they do not. Here’s the equation I want to apply to the data:
equation
Here’s a reproducible R code example of what I’m doing:
#install.packages("nnls")
library(nnls)
#create some mockup data
vector_length <- 2151
wavelengths <- seq(350, 2500, length.out = vector_length)
endmember1 <- (sin(2 * pi * wavelengths / max(wavelengths)) + 1) / 2
endmember2 <- (sin(2 * pi * wavelengths / max(wavelengths) + pi/4) + 1) / 2
endmember3 <- (sin(2 * pi * wavelengths / max(wavelengths) + pi/2) + 1) / 2
endmember_matrix <- cbind(endmember1,endmember2,endmember3)
mixed_spectra <- (sin(2 * pi * wavelengths / max(wavelengths) + 3*pi/4) + 1) / 2
#fit the nnls model into the data
fit <- nnls(endmember_matrix, mixed_spectra)
fractions <- fit$x
print(fractions)
In R, there used to be a package called hsdar, which had MESMA as a function (the package can’t now be used even in the old version of R). In Python, there is also a discontinued package which I’m unable to use called MESMA. Even Matlab has a package called Unmixing GUI last updated 8 years ago, which appears inoperational. Is there a way to conduct MESMA on data like mine in R, Python of some other (open source) software?