Train Classifier

URL:
https://<rasteranalysistools-url>/TrainClassifier
Methods:
GET
Version Introduced:
10.6.1

Description

TrainClassifier diagram

The TrainClassifier task is a service to train image classifiers in a deep learning model and return an .ecs file in JSON format. The .ecs file is used in the Classify task.

This task can be used to train a classifier using a single multiband raster or a change analysis raster generated by the AnalyzeChangesUsingCCDC or AnalyzeChangesUsingLandTrendr task. When training using a change analysis raster, the output from the Classify task will be a time series of classified rasters.

Request parameters

ParameterDetails

inputRaster

(Required)

The complete JSON raster function template (URI or by value), the complete XML raster function template (URI or value), portal item ID, image service URL, cloud raster dataset, or shared raster dataset that will be used for training. If multiple input types are provided, itemId takes priority.

Syntax: A string describes the input raster

Input raster

Example:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
//Portal Item ID
{"itemId": <portal item id>}

//Image Service URL
{"url": <image service url}

//Service Properties
{"serviceProperties":{"name":"testrasteranalysis",
  "serviceUrl":"https://<server name>/server/rest/services/Hosted/testrasteranalysis/ImageServer"},
  "itemProperties":{"itemId":"8cfbd3ec25584d0d8f4ed23b8ff7c43b", "folderId", "sdfwerfbd3ec25584d0d8f4",: }}

Raster dataset example

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
{
  "rasterFunction":"ExtractBand",
  "rasterFunctionArguments":{
    "BandIDs":[1,2,4],
    "Raster": <image service url>
  }
}

inputTrainingSampleJSON

(Required)

This is the JSON representation of the training samples. Its format is the same as the JSON converted from a training shapefile that was saved in the ArcGIS Pro Training Samples Manager pane.

Syntax: JSON object describes the training samples.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
  "displayFieldName": "",
  "fieldAliases": {
    "FID": "FID",
    "Classname": "Classname",
    "Classvalue": "Classvalue",
    "RED": "RED",
    "GREEN": "GREEN",
    "BLUE": "BLUE",
    "Count": "Count"
  },
  "geometryType": "esriGeometryPolygon",
  "spatialReference": {
    "wkid": 102719,
    "latestWkid": 2264
  },
  "fields": [
    {
      "name": "FID",
      "type": "esriFieldTypeOID",
      "alias": "FID"
    },
    {
      "name": "Classname",
      "type": "esriFieldTypeString",
      "alias": "Classname",
      "length": 254
    },
    {
      "name": "Classvalue",
      "type": "esriFieldTypeInteger",
      "alias": "Classvalue"
    },
    {
      "name": "RED",
      "type": "esriFieldTypeInteger",
      "alias": "RED"
    },
    {
      "name": "GREEN",
      "type": "esriFieldTypeInteger",
      "alias": "GREEN"
    },
    {
      "name": "BLUE",
      "type": "esriFieldTypeInteger",
      "alias": "BLUE",
    },
    {
      "name": "Count",
      "type": "esriFieldTypeInteger",
      "alias": "Count"
    }
  ],
  "features":[  ]
}

classifierParameters

(Required)

The classifier algorithm and parameters used in the supervised training.

Examples

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
//Random trees example
{"method":"rt","params": {"maxNumTrees":50,"maxTreeDepth":30,"maxSampleClass":1000}}

//Support vector machine example
{"method":"svm","params": {"maxSampleClass":1000}}

//Maximum likelihood example
{"method":"mlc"}

//K-Nearest Neighbors (KNN) example
{"method":"knn","params": {"numOfNeighbors":5,"maxSampleClass":500}}

segmentedRaster

(Optional)

The complete JSON raster function template (URI or by value), the complete XML raster function template (URI or by value), portal item ID, image service URL, cloud raster dataset, or shared raster dataset that will be used for training as the segmented raster input. If multiple inputs are provided, itemId takes priority.

Syntax: A string describes the input raster.

Example:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
//Portal Item ID
{"itemId": <portal item id>}

//Image Service URL
{"url": <image service url}

//Service Properties
{"serviceProperties":{"name":"testrasteranalysis",
  "serviceUrl":"https://<server name>/server/rest/services/Hosted/testrasteranalysis/ImageServer"},
  "itemProperties":{"itemId":"8cfbd3ec25584d0d8f4ed23b8ff7c43b", "folderId", "sdfwerfbd3ec25584d0d8f4",: }}

Raster dataset example

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
{
  "rasterFunction": "SegmentMeanShift",
  "rasterFunctionArguments": {
    "SpectralDetail": 15.5,
    "SpatialDetail": 15,
    "MinNumPixelPerSegment": 20,
    "Raster": <image service url>
  }
}

segmentAttributes

(Required)

The string of segment attributes used in the training (separated by semicolons). It is the permutation of the COLOR , MEAN , STD , COUNT , COMPACTNESS , and RECTANGULARITY attributes.

dimensionValueField

(Optional)

The field from the inputTrainingSampleJSON object that contains dimension value information. This parameter is required when using the output from the AnalyzeChangesUsingCCDC or AnalyzeChangesUsingLandTrendr task for classification.

Syntax: String

Example:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
//Portal Item ID
{"itemId": <portal item id>}

//Image Service URL
{"url": <image service url}

//Service Properties
{"serviceProperties":{"name":"testrasteranalysis",
  "serviceUrl":"https://<server name>/server/rest/services/Hosted/testrasteranalysis/ImageServer"},
  "itemProperties":{"itemId":"8cfbd3ec25584d0d8f4ed23b8ff7c43b", "folderId", "sdfwerfbd3ec25584d0d8f4",: }}

Response

When you submit a request, the task assigns a unique job ID for the transaction.

Syntax:

Use dark colors for code blocksCopy
1
2
3
4
{
"jobId": "<unique job identifier>",
"jobStatus": "<job status>"
}

After the initial request is submitted, you can use jobId to periodically review the status of the job and messages as described in Checking job status. Once the job has successfully completed, use jobId to retrieve the results. To track the status, you can make a request of the following form:

Use dark colors for code blocksCopy
1
https://<raster analysis tools url>/TrainClassifier/jobs/<jobId>

When the status of the job request is esriJobSucceeded , you can access the results of the analysis by making a request of the following form:

Use dark colors for code blocksCopy
1
https://<raster analysis tools url>/TrainClassifier/jobs/<jobId>/results/output_Classifier_Definition

The ecd is the value property of the resulting JSON.

Example usage

The following is a sample request URL for TrainClassifier :

Use dark colors for code blocksCopy
1
https://services.myserver.com/arcgis/rest/services/System/RasterAnalysisTools/GPServer/TrainClassifier/submitJob

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.