Train Classifier

Train Classifier

The Train Classifier task is a service to train supervised classifiers and return an .ecs file in JSON.

Request URL

http://<analysis url>/TrainClassifier/submitJob? inputRaster={"itemId": "780d648db3545bba8661ad98df824a4"}&
inputTrainingSampleJSON=<training sample JSON > segmentedRaster={"itemId": "780d648db3545bba8661ad98df824a4"}& 
classifierParameters={"method":"svm","params":{"maxSampleClass":1000}}segmentAttributes=COLOR;MEAN

Request Parameters

Parameter

Description

inputRaster

(Required)

The complete JSON rft (URI or by value), the complete XML rft (URI or by value), Portal Item ID, Image Service URL, cloud raster dataset, or shared raster dataset that will be used for training.

Syntax: A string describes the input raster.

Example:

{"itemId": <portal item id>}
{"url": <image service url}
{"serviceProperties":{"name":"testrasteranalysis",
  "serviceUrl":"http://<server name>/server/rest/services/Hosted/testrasteranalysis/ImageServer"},
  "itemProperties":{"itemId":"8cfbd3ec25584d0d8f4ed23b8ff7c43b", "folderId", "sdfwerfbd3ec25584d0d8f4",: }}

Example 2:

{"rasterFunction":"ExtractBand",
"rasterFunctionArguments":{"BandIDs":[1,2,4],
"Raster":<image service url>}  
}

Note: If multiple inputs are given the itemId takes the priority.

inputTrainingSampleJSON

(Required)

This is the JSON representation of the training samples. Its format is same as the JSON converted from a training shapefile that was saved out by the ArcMap image classification toolbar.

Syntax: JSON object describes the training samples.

Example:

{  
   "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":[  ]
         }
      }
   ]
}

segmentedRaster

The complete JSON rft (URI or by value), the complete XML rft (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.

Syntax: a string describes the input raster.

Example:

{"itemId": <portal item id>}
{"url": <image service url}
{"serviceProperties":{"name":"testrasteranalysis",
  "serviceUrl":"http://<server name>/server/rest/services/Hosted/testrasteranalysis/ImageServer"},
  "itemProperties":{"itemId":"8cfbd3ec25584d0d8f4ed23b8ff7c43b", "folderId", "sdfwerfbd3ec25584d0d8f4",: }}

Example 2:

{
  "rasterFunction" : "SegmentMeanShift",
  "rasterFunctionArguments" : {
       "SpectralDetail" : 15.5,
       "SpatialDetail":15,
       "MinNumPixelsPerSegment":20,
       "Raster" : <image service url>
     }  
}

Note: If multiple inputs are given the itemId takes the priority.

classifierParameters

(Required)

The classifier algorithm and parameters used in the supervised training.

Example for Random Trees:

{"method":"rt","params":{"maxNumTrees":50,"maxTreeDepth":30,
"maxSampleClass":1000}}

Example for Support Vector Machine:

{"method":"svm","params":{"maxSampleClass":1000}}

Example for Maximum Likelihood:

{"method":"mlc"}

segmentAttributes

(Required)

The string of segment attributes used in the training (separated by semicolon). It is the permutation of the following attributes: COLOR; MEAN; STD; COUNT; COMPACTNESS; RECTANGULARITY

Example: COLOR;MEAN

Response

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

Syntax:

{ "jobId": "<unique job identifier>", "jobStatus": "<job status>" }

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

http://<analysis url>/TrainClassifier/jobs/<jobId>

Accessing Results

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:

http://<analysis url>/TrainClassifier/jobs/<jobId>/results/Output_Classifier_Definition?f =json

The ecd is in the value property of the resulting JSON.

Related topics

10/6/2017