Label | Explanation | Data Type |
Input Raster | The input raster to be classified. | Mosaic Layer; Raster Layer; Image Service; String |
Input Classifier Definition File | The .ecd output classifier file from any of the train classifier tools. The .ecd file is a JSON file that contains attribute information, statistics, or other information needed for the classifier. | File |
Output Training Sample Feature Class with Score | The output individual training samples saved as a feature class. The associated attribute table contains an addition field listing the accuracy score. | Feature Class |
Output Misclassified Raster | The output misclassified raster having NoData outside training samples. In training samples, correctly classified pixels are represented as NoData, and misclassified pixels are represented by their class value. The results is an index map of misclassified class values. | Raster Dataset |
Additional Input Raster (Optional) | Ancillary raster datasets, such as a multispectral image or a DEM, will be incorporated to generate attributes and other required information for the classifier. This raster is necessary when calculating attributes such as mean or standard deviation. This parameter is optional. | Mosaic Layer; Raster Layer; Image Service; String |
Available with Spatial Analyst license.
Summary
Estimates the accuracy of individual training samples. The cross validation accuracy is computed using the previously generated classification training result in an .ecd file and the training samples. Outputs include a raster dataset containing the misclassified class values and a training sample dataset with the accuracy score for each training sample.
Usage
The tool uses the input raster, an additional input raster, and the .ecd classifier definition file to produce an on-the-fly classification layer. This classification layer is then used as reference and compared to all training sample polygons or points. Since an ideal training sample should contain only pixels of the class it represents, the accuracy is computed by comparing all the correctly classified pixels with all the incorrectly classified pixels for each training sample. The accuracy score (per polygon or point) is computed as number of correctly classified pixels/number of total pixels contained in each training sample.
The score for polygon training samples is a decimal value that ranges from 0 to 1, where a value closer to 1 means it is more accurate. The score for point training samples is either 0 for inaccurate or 1 for accurate.
The results can be used in the following ways to improve training samples defining classes:
- Use the attribute table of the output training sample to sort the training features by accuracy and zoom to each feature.
- Use the misclassified raster class map to view where classification confusion exists and what is causing it.
- Using this information, you can make a decision to keep, remove, or edit the training features.
Parameters
InspectTrainingSamples(in_raster, in_classifier_definition, out_training_feature_class, out_misclassified_raster, {in_additional_raster})
Name | Explanation | Data Type |
in_raster | The input raster to be classified. | Mosaic Layer; Raster Layer; Image Service; String |
in_classifier_definition | The .ecd output classifier file from any of the train classifier tools. The .ecd file is a JSON file that contains attribute information, statistics, or other information needed for the classifier. | File |
out_training_feature_class | The output individual training samples saved as a feature class. The associated attribute table contains an addition field listing the accuracy score. | Feature Class |
out_misclassified_raster | The output misclassified raster having NoData outside training samples. In training samples, correctly classified pixels are represented as NoData, and misclassified pixels are represented by their class value. The results is an index map of misclassified class values. | Raster Dataset |
in_additional_raster (Optional) | Ancillary raster datasets, such as a multispectral image or a DEM, will be incorporated to generate attributes and other required information for the classifier. This raster is necessary when calculating attributes such as mean or standard deviation. This parameter is optional. | Mosaic Layer; Raster Layer; Image Service; String |
Code sample
This example inspects the suitability of training samples for classification.
### InspectTrainingSamples example 1 (Python window)
import arcpy
from arcpy.ia import *
in_img = "C:/Data/wv2.tif"
trn_samples1 = "C:/out/ts.shp"
ecd = "C:/Data/svm.ecd"
seg_in_img = "C:/Data/seg.tif"
trn_samples2 = "C:/out/ts2.shp"
# Check out the ArcGIS Image Analyst extension license
arcpy.CheckOutExtension("ImageAnalyst")
out_misclassified_raster = InspectTrainingSamples(in_img, trn_samples, ecd,
trn_samples2, seg_in_img);
out_misclassified_raster.save("C:/temp/misclassified.tif")
This example inspects the suitability of training samples for classification.
### InspectTrainingSamples example 2 (stand-alone script)
import arcpy
from arcpy.ia import *
# Check out the ArcGIS Image Analyst extension license
arcpy.CheckOutExtension("ImageAnalyst")
out_misclassified_raster = InspectTrainingSamples("C:/Data/wv2.tif",
"C:/out/ts.shp",
"C:/Data/svm.ecd",
"C:/out/ts2.shp",
"C:/Data/seg.tif");
out_misclassified_raster.save("C:/temp/misclassified.tif")