knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This vignette demonstrates a complete workflow for processing multispectral satellite imagery using GeoIndexR and terra:
library(GeoIndexR) library(terra) # Load synthetic 6-band multispectral raster img <- get_example_data() print(img) names(img)
Satellite images often use sensor-specific band notations (such as B02, B03, B04, B08 for Sentinel-2, or B2, B3, B4, B5 for Landsat 8/9).
GeoIndexR supports sensor presets:
# View pre-configured Sentinel-2 bands band_mapping("sentinel2") # View pre-configured Landsat 8/9 bands band_mapping("landsat8")
If your image layers use non-standard names, you can pass a custom named vector:
my_mapping <- c( blue = "blue", green = "green", red = "red", nir = "nir", swir = "swir1" )
Compute a multi-index suite covering vegetation, water, urban built-up, and soil:
indices <- geo_indices( image = img, indices = c("NDVI", "NDWI", "NDBI", "SAVI", "BSI"), bands = my_mapping ) print(indices) names(indices)
Use index_summary() to inspect the distributions across all computed layers:
stats <- index_summary(indices) print(stats)
plot_index() applies scientifically tailored palettes based on index categories:
# Visualizing NDVI plot_index(indices, index = "NDVI")
terra::writeRasterSince all outputs returned by GeoIndexR are standard terra::SpatRaster objects with full CRS and geotransform preservation, saving results to GeoTIFF or COG is simple:
# Export the multilayer raster to GeoTIFF terra::writeRaster(indices, "computed_indices.tif", overwrite = TRUE)
This ensures complete compatibility with GDAL, QGIS, ArcGIS, Python rasterio, and web mapping services.
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.