Generate Training Samples From Seed Points (Spatial Analyst)

Available with Spatial Analyst license.

Available with Image 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.

Syntax

GenerateTrainingSamplesFromSeedPoints(in_class_data, in_seed_points, out_training_feature_class, {min_sample_area}, {max_sample_radius})
ParameterExplanationData Type
in_class_data

The data source that labels the training samples.

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

A point shapefile or feature class to provide the centers of training sample polygons.

Feature Layer
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")

Licensing information

  • Basic: Requires Spatial Analyst or Image Analyst
  • Standard: Requires Spatial Analyst or Image Analyst
  • Advanced: Requires Spatial Analyst or Image Analyst

Related topics