library(RStoolbox)
library(terra)
# to perform a SMA, use a single endmember per class, row by row:
em <- data.frame(lsat[c(5294, 47916)])
rownames(em) <- c("forest", "water")
# umix the lsat image
probs <- mesma(img = lsat, em = em)
plot(probs)
# to perform a MESMA, use multiple endmembers per class, differntiating them
# by a column named 'class':
if (FALSE) {
em <- rbind(
data.frame(lsat[c(4155, 17018, 53134, 69487, 83704)], class = "forest"),
data.frame(lsat[c(22742, 25946, 38617, 59632, 67313)], class = "water")
)
# unmix the lsat image
probs <- mesma(img = lsat, em = em)
plot(probs)
# MESMA can also be performed on more than two endmember classes:
em <- rbind(
data.frame(lsat[c(4155, 17018, 53134, 69487, 83704)], class = "forest"),
data.frame(lsat[c(22742, 25946, 38617, 59632, 67313)], class = "water"),
data.frame(lsat[c(4330, 1762, 1278, 1357, 17414)], class = "shortgrown")
)
# unmix the lsat image
probs <- mesma(img = lsat, em = em)
plot(probs)
}
Run the code above in your browser using DataLab