GRASS logo

NAME

p.spec.pca - Principal Component Analysis of a multi-band planetary raster.
Computes PCA via cyclic Jacobi eigendecomposition of the pixel covariance matrix (or correlation matrix with -s). Reads bands named input.1, input.2, ... and writes PC score rasters output.1, output.2, ... in descending variance order. Eigenvalues, cumulative variance explained, and eigenvectors are written to a CSV file.

KEYWORDS

Planetary, Spectral & Mineral Mapping, PCA, principal component analysis, hyperspectral

SYNOPSIS

p.spec.pca
p.spec.pca --help
p.spec.pca [-s] input=string output=string [ncomps=integer] [stats=string] [--help] [--verbose] [--quiet] [--ui]

Flags:

-s
Standardise bands (correlation-matrix PCA): divide each band by its standard deviation before PCA. Recommended when bands span very different value ranges.
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--ui
Force launching GUI dialog

Parameters:

input=string [required]
Base name of input band rasters (input.1, input.2, ...)
output=string [required]
Base name for output PC score rasters (output.1, output.2, ...)
ncomps=integer
Number of PC components to write (0 = all bands)
Default: 0
stats=string
Output CSV file for eigenvalues, variance explained, and eigenvectors

Table of contents

DESCRIPTION

p.spec.pca computes Principal Component Analysis (PCA) of a multi-band planetary raster. It reads bands named input.1, input.2, …, builds the per-pixel covariance (or correlation) matrix, performs an exact eigendecomposition via the cyclic Jacobi algorithm, and writes the requested number of PC score rasters in descending explained-variance order.

What PCA does in planetary spectroscopy

PCA rotates the band space so that PC-1 captures the most variance (often dominated by albedo / illumination), PC-2 captures the next independent source of variance (often a broad spectral slope), and higher PCs progressively isolate weaker, instrument-noise-free signal components (absorption features, compositional boundaries). Displaying PC-2/PC-3/PC-4 as a false-colour composite is the standard first step for highlighting mineralogic boundaries in CRISM, OMEGA, and M3 data.

Covariance vs correlation PCA (-s flag)

Without -s (default) the covariance matrix of the raw band values is used. This is appropriate when all bands are in the same physical unit and comparable range (e.g. CRISM I/F reflectance). With -s each band is first divided by its standard deviation (equivalent to using the correlation matrix). Use -s when bands span very different value ranges, such as when mixing VNIR and SWIR channels with different absolute radiance scales.

Eigenvalue CSV (stats=)

The output CSV contains one row per PC with columns:

The loadings show which input bands contribute most to each PC. A large positive or negative loading at a specific wavelength indicates that absorption feature drives that PC.

NOTES

EXAMPLES

Basic PCA of a CRISM VNIR group (544 bands, default covariance):

p.spec.pca input=crism_frt0003bfb output=crism_pc \
    ncomps=10 stats=crism_pca_stats.csv

Display PC-2/PC-3/PC-4 as false colour (standard mineralogy composite):

d.rgb red=crism_pc.2 green=crism_pc.3 blue=crism_pc.4

Correlation-matrix PCA (standardised bands) for OMEGA with mixed channels:

p.spec.pca input=omega_orb100 output=omega_pc -s ncomps=6

REFERENCES

SEE ALSO

p.spectral.planet, p.mineral.indices, p.spec.class

SOURCE CODE

Available at: p.spec.pca source code (history)

Accessed: Sunday Nov 15 11:06:08 2026


Main index | Paint index | Topics index | Keywords index | Graphical index | Full index

© 2003-2026 GRASS Development Team, GRASS 8.5.1dev Reference Manual