Classify Raster Using Spectra (Image Analyst)

Available with Image Analyst license.

Available with Spatial Analyst license.

Summary

Classifies a multiband raster dataset using spectral matching techniques. The input spectral data can be provided as a point feature class or a .json file.

Usage

  • If the input .json file contains spectral values that are provided as percent surface reflectance, the raster dataset must be rescaled using a sensor-specific scaling factor. For example, Landsat 8 and 9 collection 2 level-2 surface reflectance products can be rescaled to 0–1 using the following expression: Raster*0.0000275+(-0.2).

  • After applying scaling and offset factors, negative values can occur, especially over dark features such as water. These negative pixels must be masked prior to using the SID classification method.

  • The order of the output classified raster follows the order of the input spectral profile.

  • The following is an example of a spectral profile provided as a .json file:

    
    {
      "EsriEndmemberDefinitionFile" : 0,
      "FileVersion" : 1,
      "NumberOfEndmembers" : 4,
      "NumberOfBands" : 7,
      "Endmembers" : [	
        {
          "EndmemberID" : 1,
          "EndmemberName" : "basalt",
          "SpectralProfile" : [
                0.076036952,
    			                       0.08137,
    			                       0.09371,
    			                       0.10768,
    			                       0.11076,
    			                       0.11424,
    			                       0.09824
              ]
        }, 
        {
          "EndmemberID" : 2,
          "EndmemberName" : "quartz",
          "SpectralProfile" : [
                              0.75812,
                              0.77608,
                              0.80143,
                              0.81418,
                              0.82648,
                              0.85234,
                              0.86170
              ]
        },
        {
          "EndmemberID" : 3,
          "EndmemberName" : "salt deposits",
          "SpectralProfile" : [
                              0.53381,
                              0.59598,
                              0.70402,
                              0.79024,
                              0.86628,
                              0.89397,
                              0.89507
              ]
        },
        {
          "EndmemberID" : 4,
          "EndmemberName" : "limestone",
          "SpectralProfile" : [
                              0.15477,
                              0.16733,
                              0.19435,
                              0.21431,
                              0.24765,
                              0.32578,
                              0.32451
              ]
        }
      ]        
    }
  • The point features require the following fields:

    • classname—A text field indicating the name of the class category
    • classvalue—A long integer field containing the integer value for each class category
  • An output Esri classifier definition file (.ecd) can be used as a input to the Classify Raster tool.

Parameters

LabelExplanationData Type
Input Raster

The input multiband raster.

Mosaic Layer; Raster Layer; Image Service; String; Raster Dataset; Mosaic Dataset
Spectra or Points

The spectral information for different pixel classes.

The spectral information can be provided as point features, a training sample point feature class generated from the Training Samples Manager pane, or a .json file that contains the class spectral profiles.

Feature Layer; File; String
Method

Specifies the spectral matching method that will be used.

  • Spectral Angle MapperThe vector angle between the input multiband raster and the reference spectra will be calculated in which the spectra of each pixel is treated as a vector. Angle values are in radians.
  • Spectral Information DivergenceThe spectral information divergence between the input multiband raster and the reference spectra will be calculated. A score will be calculated for each pixel based on the divergence between the probability distributions of the pixel and reference spectra. Values are in radians.
String
Thresholds
(Optional)

The threshold for spectral matching. Pixel values that exceed this value will be classified as undefined. This can be a single value applied to all spectral classes or a space-delimited list of values for each class.

String
Output Score Raster
(Optional)

A multiband raster that stores the matching results for each end member. The band order follows the order of the classes in the Spectra or Points parameter value. If the input is a multidimensional raster, the output format must be CRF.

Raster Dataset
Output Classifier Definition File
(Optional)

The output .ecd file.

File

Return Value

LabelExplanationData Type
Output Classified Raster

The output classified raster.

Raster

ClassifyRasterUsingSpectra(in_raster, in_spectra_file, method, {thresholds}, {out_score_raster}, {out_classifier_definition})
NameExplanationData Type
in_raster

The input multiband raster.

Mosaic Layer; Raster Layer; Image Service; String; Raster Dataset; Mosaic Dataset
in_spectra_file

The spectral information for different pixel classes.

The spectral information can be provided as point features, a training sample point feature class generated from the Training Samples Manager pane, or a .json file that contains the class spectral profiles.

Feature Layer; File; String
method

Specifies the spectral matching method that will be used.

  • SAMThe vector angle between the input multiband raster and the reference spectra will be calculated in which the spectra of each pixel is treated as a vector. Angle values are in radians.
  • SIDThe spectral information divergence between the input multiband raster and the reference spectra will be calculated. A score will be calculated for each pixel based on the divergence between the probability distributions of the pixel and reference spectra. Values are in radians.
String
thresholds
(Optional)

The threshold for spectral matching. Pixel values that exceed this value will be classified as undefined. This can be a single value applied to all spectral classes or a space-delimited list of values for each class.

String
out_score_raster
(Optional)

A multiband raster that stores the matching results for each end member. The band order follows the order of the classes in the in_spectra_file parameter value. If the input is a multidimensional raster, the output format must be CRF.

Raster Dataset
out_classifier_definition
(Optional)

The output .ecd file.

File

Return Value

NameExplanationData Type
out_classified_raster

The output classified raster.

Raster

Code sample

ClassifyRasterUsingSpectra example 1

This example performs Spectral Angle Mapping (SAM) on a Landsat 8 raster with thresholds specified for each class. The reference spectra are provided in a .json file.

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

#Check out ArcGIS Image Analyst extension license
arcpy.CheckOutExtension("ImageAnalyst")

# Set local variables
in_raster = "C:/Data/LandSat8_SurfaceReflectance.tif"
in_spectra_file = "C:/Data/ref_spectra.json"
method = "SAM"
thresholds = ".08 .04 .05 .07"
out_score_raster = "C:/Data/scoreSAM.crf"
out_classifier_definition = "C:/Data/SAM_classifier.ecd"

# Execute 
Classified_output = arcpy.ia.ClassifyRasterUsingSpectra(in_raster, in_spectra_file, method, thresholds, out_score_raster, out_classifier_definition)

# Save output
Classified_output.save("C:/data/Classified_output.crf")
ClassifyRasterUsingSpectra example 2

This example calculates the Spectral Information Divergence (SID) between a Landsat 8 raster and reference spectra derived from a point feature class.

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

#Check out ArcGIS Image Analyst extension license
arcpy.CheckOutExtension("ImageAnalyst")

# Set local variables
in_raster = "C:/Data/LandSat8_SurfaceReflectance.tif"
in_spectra_file = "C:/Data/ref_spectra.shp"
method = "SID"
thresholds = .08
out_score_raster = "C:/Data/scoreSID.crf"
out_classifier_definition = "C:/Data/SID_classifier.ecd"

# Execute 
Classified_output = arcpy.ia.ClassifyRasterUsingSpectra(in_raster, in_spectra_file, method, thresholds, out_score_raster, out_classifier_definition)

# Save output
Classified_output.save("C:/data/Classified_output.crf")

Related topics