End-to-End Multispectral Image Workflow

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Introduction

This vignette demonstrates a complete workflow for processing multispectral satellite imagery using GeoIndexR and terra:

  1. Loading imagery
  2. Identifying bands and mapping sensor aliases
  3. Calculating targeted and comprehensive indices
  4. Validating and summarizing distributions
  5. Visualizing results with thematic color maps
  6. Exporting georeferenced GeoTIFF files

Step 1: Loading Imagery & Inspecting Bands

library(GeoIndexR)
library(terra)

# Load synthetic 6-band multispectral raster
img <- get_example_data()
print(img)
names(img)

Step 2: Band Mapping & Sensor Presets

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"
)

Step 3: Computing Multiple Indices

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)

Step 4: Summary Statistics

Use index_summary() to inspect the distributions across all computed layers:

stats <- index_summary(indices)
print(stats)

Step 5: Visualization

plot_index() applies scientifically tailored palettes based on index categories:

# Visualizing NDVI
plot_index(indices, index = "NDVI")

Step 6: Exporting with terra::writeRaster

Since 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.



Try the GeoIndexR package in your browser

Any scripts or data that you put into this service are public.

GeoIndexR documentation built on Oct. 10, 2026, 5:08 p.m.