SpectralConversion

Synthèse

Applies a matrix to a multiband image to affect the color values of the output.

Discussion

For more information about how this function works, see the Spectral Conversion raster function.

The referenced raster dataset for the raster object is temporary. To make it permanent, you can call the raster object's save method.

Syntaxe

SpectralConversion (raster, conversion_matrix)
ParamètreExplicationType de données
raster

The input raster.

This can be a raster dataset within a mosaic dataset or raster catalog, or a raster dataset outside the mosaic dataset.

Raster
conversion_matrix

The matrix used to convert the input raster.

The equation used to perform this conversion is as follows:

Output Band_R = Weight_P * Band_C

where:

  • Band_R is an output band, where R is a number from 1 to the number of output bands.
  • Weight_P is a comma-delimited list of weights, 1 for each input band. The sum of the weights for each band should equal 1.
  • Band_C is the input image, where C is a number from 1 to the number of bands of the input image.

Raster
Valeur renvoyée
Type de donnéesExplication
Raster

The output raster.

Exemple de code

SpectralConversion example 1

This example is applying a matrix to a multiband image to change the color values of the output.

from arcpy.sa import *
out_raster = SpectralConversion("3bands_raster",
                                [0.1, 0.9, 0, 0.3, 0, 0.7, 0.1, 0.1, 0.8])
out_raster.save("C:/arcpyExamples/outputs/out_spectralconversion_raster.tif")
SpectralConversion example 2

This example is applying a matrix to a multiband image to change the color values of the output.

# Import system modules
import arcpy
from arcpy.sa import *

# Set the analysis environments
arcpy.env.workspace = "C:/arcpyExamples/data"

# Set the local variables
in_raster = "3bands_raster"
in_conversion_matrix =  [0.1, 0.9, 0, 0.3, 0, 0.7, 0.1, 0.1, 0.8]

# Execute SpectralConversion function
out_raster = SpectralConversion(in_raster, in_conversion_matrix)
#Output band 1 = (0.1 * InputBand1) + (0.9 * InputBand2) +(0 * InputBand3)
#Output band 2 = (0.3 * InputBand1) + (0 * InputBand2) +(0.7 * InputBand3)
#Output band 3 = (0.1 * InputBand1) + (0.1 * InputBand2) +(0.8 * InputBand3)

# Save output
out_raster.save("C:/arcpyExamples/outputs/out_spectralconversion_raster.tif")

Rubriques connexes