if (FALSE) {
# NDVI
si <- rsi::spectral_indices() # retrieves spectral indices
ndvi <- subset(si, short_name == "NDVI") # creates one-row data.frame
ndvi_script <- MakeEvalScript(ndvi) # generates the script
cat(ndvi_script, sep = "\n")
# SAVI, which requires the constant L
cat(MakeEvalScript("SAVI", L = 0.5), sep = "\n", file = "SAVI.js")
# Using a custom index definition as a data.frame
custom_index <- data.frame(
short_name = "GNDVI",
long_name = "Green Normalized Difference Vegetation Index",
platforms = I(list("Sentinel-2")),
bands = I(list(c("N", "G"))),
formula = "(N - G) / (N + G)"
)
cat(MakeEvalScript(custom_index))
}
Run the code above in your browser using DataLab