Nothing
## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
## ----step1--------------------------------------------------------------------
library(GeoIndexR)
library(terra)
# Load synthetic 6-band multispectral image
img <- get_example_data()
print(img)
names(img)
## ----step2--------------------------------------------------------------------
# Band mapping by explicit role name
bands_map <- c(red = "red", nir = "nir", blue = "blue")
## ----step3--------------------------------------------------------------------
ndvi <- geo_index(img, "NDVI", bands = bands_map)
print(ndvi)
## ----step4--------------------------------------------------------------------
summary_tbl <- index_summary(ndvi)
print(summary_tbl)
## ----step5, fig.width = 6, fig.height = 5-------------------------------------
plot_index(ndvi, "NDVI")
## ----step6, eval = FALSE------------------------------------------------------
# writeRaster(ndvi, "NDVI_output.tif", overwrite = TRUE)
## ----step7--------------------------------------------------------------------
# Compute a custom ratio
custom_ratio <- geo_index_custom(
img,
formula = "(nir - red) / (nir + red)",
bands = c(red = "red", nir = "nir"),
name = "MyCustomNDVI"
)
print(custom_ratio)
# Compute a custom parameterized index
custom_veg <- geo_index_custom(
img,
formula = "G * (nir - red) / (nir + C1 * red - C2 * blue + L)",
bands = c(blue = "blue", red = "red", nir = "nir"),
params = list(G = 2.5, C1 = 6.0, C2 = 7.5, L = 1.0),
name = "CustomEVI"
)
print(custom_veg)
## ----step8--------------------------------------------------------------------
# Mock integer DN raster
img_dn <- img * 10000
# Calculate EVI with proper scale factor conversion
evi_scaled <- geo_index(
img_dn,
"EVI",
bands = c(blue = "blue", red = "red", nir = "nir"),
scale_factor = 10000
)
index_summary(evi_scaled)
## ----step9--------------------------------------------------------------------
reg <- index_registry(category = "vegetation")
reg[, c("index", "name", "required_bands", "requires_reflectance")]
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.