Generate Training Samples From Seed Points (Spatial Analyst)

Available with Spatial Analyst license.

Summary

Generates training samples from seed points, such as accuracy assessment points or training sample points. A typical use case is generating training samples from an existing source, such as a thematic raster or a feature class.

Usage

  • This tool accepts third party data sources into the ArcGIS classification toolset. Inputs that identify the class schema to guide the generation of training samples includes thematic raster data sets, or polygons such as previous classification maps, building footprints, roads, or other GIS data.

  • For raster inputs, the tool will perform a region grow from seed points, under the condition that all pixels have the same value. Region grow is controlled by Max Sample Radius (in Python it is max_radius). Best practices in remote sensing suggest training samples should be homogeneous within the training sample, and the size of the sample should be representative of the target feature. If region grow from certain seed points cannot reach an area larger than Min Sample Area (in Python it is min_area), the seed point is not used.

  • For feature class inputs, the tool will select features from input data that intersect the point feature class, instead of using region grow.

  • You can use the Create Accuracy Assessment Points tool for generating the training sample points. It presents options for the number of points to use and a few sampling strategies for generating the random points.

  • If you already have training sample seed points or a way to generate them, these can be easily used since the tool only uses the x and y coordinates of a point feature class file, not the associated table.

Parameters

LabelExplanationData Type
Input Raster or Feature Class Data

The data source that labels the training samples.

Mosaic Layer; Raster Layer; Feature Layer; Image Service; String
Output Training Sample Feature Class

The output training sample feature class in the format that can be used in training tools, including shapefiles. The output feature class can be either a polygon feature class or a point feature class.

Feature Class
Min Sample Area
(Optional)

The minimum area needed for each training sample, in square meters. The minimum value must be greater than or equal to 0.

Double
Max Sample Radius
(Optional)

The longest distance (in meters) from any point within the training sample to its center seed point. If set to 0, the output training sample will be points instead of polygons. The minimum value must be greater than or equal to 0.

Double

GenerateTrainingSamplesFromSeedPoints(in_class_data, out_training_feature_class, {min_sample_area}, {max_sample_radius})
NameExplanationData Type
in_class_data

The data source that labels the training samples.

Mosaic Layer; Raster Layer; Feature Layer; Image Service; String
out_training_feature_class

The output training sample feature class in the format that can be used in training tools, including shapefiles. The output feature class can be either a polygon feature class or a point feature class.

Feature Class
min_sample_area
(Optional)

The minimum area needed for each training sample, in square meters. The minimum value must be greater than or equal to 0.

Double
max_sample_radius
(Optional)

The longest distance (in meters) from any point within the training sample to its center seed point. If set to 0, the output training sample will be points instead of polygons. The minimum value must be greater than or equal to 0.

Double

Code sample

GenerateTrainingSamplesFromSeedPoints example 1 (Python window)

Create training samples from seed points.

### GenerateTrainingSamplesFromSeedPoints example 1 (Python window)
import arcpy
from arcpy.sa import *

cls_img = "C:/Data/svm.tif"
seed_pnts = "C:/Data/seeds.shp"
trn_samples = "C:/out/ts.shp"

GenerateTrainingSamplesFromSeedPoints(cls_img, seed_pnts, trn_samples, "30", "50")
GenerateTrainingSamplesFromSeedPoints example 2 (stand-alone script)

Create training samples from seed points.

### GenerateTrainingSamplesFromSeedPoints example 2 (stand-alone script)
import arcpy
from arcpy.sa import *

GenerateTrainingSamplesFromSeedPoints("C:/Data/svm.tif", 
                                      "C:/Data/seeds.shp", 
                                      "C:/out/ts.shp", 
                                      "30", "50")

Related topics