An Update to Spectral Unmixing with RStoolbox

Multiple Endmember Spectral Mixture Analysis (MESMA) is a method to estimate the fractions of light reflected by different surfaces or materials within a pixel of a remotely sensed multi-spectral image. It is a so-called sub-pixel approach, as information about the composition of a single pixel, e.g. in satellite imagery, can be derived.

For example, the reflection signal represented by a 10 by 10 meter Sentinel-2 pixel may consist of a number of spectral signatures, e.g. stemming from vegetation canopies, open soils, asphalt, or roofs. These spectral signatures mix into one reflection signal at the scale of a sensor’s spatial resolution, creating a mixed pixel. With spectral unmixing, one can try to decompose this mixed signal into the components of the reflected light it originated from.

Spectral unmixing in RStoolbox using mesma()

Spectral unmixing can be applied using RStoolbox, a toolbox for remote sensing data analysis, implemented in R and co-developed at the Earth Observation Research Cluster (EORC) at University of Würzburg. The function implementing spectral unmixing in RStoolbox is called mesma(). It allows users to supply a raster containing spatio-spectral information, and a set of so called endmembers.

Endmembers are spectral signatures of surfaces or materials that should be used to unmix pixels with. mesma() uses a solving algorithm to determine how much each endmember may have contributed to the synthesis of the mixed signal. The solving algorithm, a sequential coordinate-wise Non-Negative Least Squares (NNLS) regression (Franc et al., 2005), is applied on different combinations of endmembers.

Concurrent with the MESMA approach proposed by Roberts et al. (1998), mesma() selects the best-performing model per pixel based on the lowest Root Mean Square Error (RMSE) across all endmember combinations run. As a result, the estimated fraction (abundance) of each endmember class is returned for each pixel. This way, a user can for example estimate, how much vegetation is present in a densely build urban environment, where rarely a complete 10 by 10 meter pixel is purely covered by vegetation. Instead, individual plants are usually embedded in surrounding surfaces made out of concrete, gravel, asphalt and the likes.

Recently, the RStoolbox software package has been updated to further optimise the mesma() and to fix issues users have encountered.

Exploiting the maximum number of possible endmember combinations

If one supplies multiple endmembers each associated wit a class, mesma() has been picking a combination of endmembers used in unmixing. For this selection, mesma() has randomly sampled combinations of endmembers. The number of selections made could be controlled using the n_models argument. Thus, each time mesma() has been rerun without resetting the session seed, a different selection of endmembers could have been drawn by chance. We have decided that this behaviour is not optimal.

To date, the default of n_models always was determined by the minimum number of endmembers per class present, which did not represent the maximum number of potential combinations of endmembers and thus underutilised the supplied set of endmembers. For example, a set of endmembers of three different surface classes and three endmembers per class results in 27 possible combinations of endmembers across classes. Until recently, only three of these 27 combinations were used. In addition, the user was denied setting a greater number of combinations through the n_models argument, e.g. to such a value equal to the maximum number of endmember combinations across classes.

Thus, in the most recent RStoolbox update to version 1.0.2.3, we have changed the source code of mesma(): It now picks all possible endmember combinations by default, setting n_models to the maximum number of endmember combinations computed. This way, all runs that have identical solver settings (iterate, tolerance) yield the same result (i.e. the result with the lowest RMSE achievable with NNLS for the set of solver settings). If the user chooses to decrease n_models, e.g. for performance reasons, endmember combinations are picked randomly as before. One can force identical sets of endmembers being used by setting identical session seeds each time right before calling mesma().

Fixing a bug occurring when only one endmember per class is supplied

In addition, we found a bug that previously had gone unnoticed: In the unusual case that someone supplies an endmember set with just one endmember per class, but includes the class column (even though each endmember only represent its own class), mesma() did not recognise that to be a Spectral Mixture Analysis (SMA) problem rather than a MESMA problem. An error in the code caused the function to create false sets of endmembers. The error did not occur and results were as expected, if the class column was left out, which indicates a one-endmember-per-class input to mesma(). We have fixed this issue with the recent RStoolbox update, too.

We have also updated the user manual of mesma() to specify how endmember selection is done. The above-mentioned changes are available on GitHub and will soon be part of the binaries for Windows/Mac users via CRAN and r-universe.

To learn more about RStoolbox, visit our docs or read our paper published in Methods in Ecology and Evolution.