## NAME

i.hyper.composite.py - Create RGB/CIR/SWIR and custom false color composites from a hyperspectral 3D raster map.

## KEYWORDS

imagery, hyperspectral, composite

## SYNOPSIS

i.hyper.composite.py
i.hyper.composite.py --help
i.hyper.composite.py map=name output=string [composites=string[,string,...]] [composites_custom=string] [strength=integer] [--help] [--verbose] [--quiet] [--ui]

### Flags:

--help
  Print usage summary
--verbose
  Verbose module output
--quiet
  Quiet module output
--ui
  Force launching GUI dialog

### Parameters:

map=name [required]
  Input hyperspectral 3D raster map
output=string [required]
  Output name prefix for composites
composites=string[,string,...]
  Which composites to generate
  Options: rgb, cir, swir_agriculture, swir_geology
composites_custom=string
  Custom wavelengths (nm) as R,G,B (e.g., 2200,848,572)
strength=integer
  i.colors.enhance 'strength' (0-100). RGB uses -p; others no -p.
  Default: 96

## DESCRIPTION

i.hyper.composite creates RGB, CIR, SWIR and custom false-color composites from a hyperspectral 3D raster map (`raster_3d`). The module reads per-band wavelength metadata from the 3D raster (as written by i.hyper.import / i.hyper.preproc), selects the nearest available bands to requested wavelengths, enhances contrast, and composes a 2D color raster.

Internally, the cube is temporarily exploded into 2D rasters (one per band) using `r3.to.rast`. For each composite, the nearest bands to target wavelengths are chosen, optional color enhancement is applied with `i.colors.enhance`, and the final composite is produced with `r.composite`. Temporary rasters and the temporary region are automatically cleaned up.

Predefined composites are provided for common use-cases; custom triplets (R,G,B in nm) are supported for sensor-agnostic workflows.

## FUNCTIONALITY

Built-in composites (target wavelengths in nm):

- rgb â€” [660, 572, 478] (true color)
- cir â€” [848, 660, 572] (color-infrared)
- swir_agriculture â€” [848, 1653, 660] (vegetation/wetness contrast)
- swir_geology â€” [2200, 848, 572] (mineral/rock contrast)

Custom composite: specify `composites_custom=R,G,B` (wavelengths in nm), e.g. `2200,848,572` or `560,860,1640`. The module selects the nearest available band to each requested wavelength; it does not resample spectrally.

## NOTES

- The input 3D raster must contain per-band wavelength comments in `r3.info` (e.g., lines like `Band 17: 848 nm`); otherwise the module aborts with a clear error.
- Nearest-band selection is used (no spectral resampling). If your cubeâ€™s wavelengths differ from the requested targets, the closest bands are chosen.
- `i.colors.enhance` is run with the provided `strength` (0â€“100). For the rgb composite, the `-p` flag is used to preserve natural RGB balance; other composites run without `-p`.
- A temporary 3D region is set to the cube; the original region is restored. Temporary 2D rasters are removed on exit.
- Requires at least 3 bands in the input cube.

## OPTIONS

- `map` â€” input hyperspectral 3D raster map (required).
- `output` â€” output name prefix for generated composites (required).
- `composites=rgb,cir,swir_agriculture,swir_geology` â€” list of presets to create (optional, multiple allowed).
- `composites_custom=R,G,B` â€” custom wavelengths in nm, e.g. `2200,848,572` (optional).
- `strength` â€” enhancement strength for `i.colors.enhance` (0â€“100, default: 96).

## EXAMPLES

    # Set the region
    g.region raster_3d=prisma

    # Example 1: True color (RGB) and CIR from PRISMA
    i.hyper.composite map=prisma output=prisma \
                      composites=rgb,cir

    # Console output:
    Generated composite raster: prisma_rgb
    Generated composite raster: prisma_cir

    # Example 2: SWIR geology composite from EnMAP

    # Set the region
    g.region raster_3d=enmap

    i.hyper.composite map=enmap output=enmap \
                      composites=swir_geology strength=90

    # Console output:
    Generated composite raster: enmap_swir_geology

    # Example 3: Custom Snow/Ice composite (Greenâ€“NIRâ€“SWIR)

    # Set the region
    g.region raster_3d=tanager

    # Uses nearest bands to 560, 860, and 1640 nm
    i.hyper.composite map=tanager output=snowice \
                      composites_custom=560,860,1640 strength=92

    # Console output:
    Generated composite raster: snowice_custom

## SEE ALSO

i.hyper.import, i.hyper.preproc, i.hyper.explore, i.hyper.export, r3.to.rast, r.composite, i.colors.enhance, g.region, r3.info

## AUTHORS

Alen MangafiÄ‡ and TomaÅ¾ Å½agar, Geodetic Institute of Slovenia

## SOURCE CODE

Available at: i.hyper.composite source code (history)

Latest change: Tue Jan 6 21:39:11 2026 in commit: 22f101f1686a37f902e9631c79a905d905c66bf2

Main index | Imagery index | Topics index | Keywords index | Graphical index | Full index

© 2003-2022 GRASS Development Team, GRASS GIS 8.0.2 Reference Manual