Skip To Content
ArcGIS Developer
Dashboard

Segment

Description

Segment diagram

The Segment task groups together adjacent pixels having similar spectral and spatial characteristics into segments, known as objects. The input raster dataset can be clipped, resampled, and reprojected based on the setting.

Request parameters

ParameterDetails
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 segmented. If multiple inputs are given, then itemId takes priority. If a complete rft is given, then spectralDetail, spatialDetail, minimumSegmentSizeInPixels, and bandIndexes will not be honored. This option is used by ArcGIS Pro and web apps.

Syntax: A string describes the input raster.

Example:

//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",: }}

outputName

(Required)

The location where the service will generate the output raster.

Syntax: JSON object that describes the output raster.

Example:

//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",: }}

spectralDetail

Sets the level of importance given to the spectral differences of features in your imagery. Valid values range fro 1.0-20.0. A high value is appropriate when you have features you want to classify separately but have somewhat similar spectral characteristics. Smaller values create spectrally smoother outputs. For example, setting a higher spectral detail value for a forested scene will preserve greater discrimination between the different tree species, resulting in more segments.

Example

SpectralDetail=15.5
spatialDetail

Sets the level of importance given to the proximity between features in your imagery. Valid values range from 1-20. A high value is appropriate for a scene where your features of interest are small and clustered together. Smaller values create spatially smoother outputs. For example, in an urban scene you could classify an impervious surface using a smaller spatial detail, or you could classify buildings and roads as separate classes using a higher spatial detail.

Example

SpatialDetail=15
minimumSegmentSizeInPixels

Merges segments smaller than this size with their best fitting neighbor segment. This is related to the minimum mapping unit for a mapping project. Units are in pixels.

Example

minimumSegmentSizeInPixels=20
bandIndexes

Defines which 3 bands are used in segmentation. Choose the bands that visually discriminate your features of best interest. The value is a string of three numbers separated by three commas.

Example

bandIndexes: "0, 1, 2"
removeTilingArtifacts

If the value is false or 0, the tool will not run to remove tiling artifacts after segmentation. The result may seem blocky at some tiling boundaries.

Example

removingTilitingArtifacts="true"

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 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:

https://<raster analysis tools url>/Segment/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:

https://<raster analysis tools url>/Segment/jobs/<jobId>/results/outputRaster

Example usage

The following is a sample request URL for Segment:

https://services.myserver.com/arcigs/rest/services/System/RasterAnalysisTools/GPServer/Segment/submitJob

JSON Request example

inputRaster={"itemId": "1780d648db3545bba8661ad98df824a4"}&
outputName={"itemId": "04180233981a4b978755d854687e149e"}&
spectralDetail=15.5&
spatialDetail=15&
minimumSegmentSizeInPixels=20&
bandIndexes="0,1,2"&
removeTilingArtifacts="true"

JSON Response example

The response returns the outputRaster output parameters, which has properties for parameter name, data type, and value. The content of value is always the output raster dataset itemId and the image service URL.

{
 "paramName": "outputRaster",
 "dataType": "GPString",
 "value": {
  "itemId": "f121390b85ef419790479fc75b493efd", 
  "url": "https://<server name>/arcgis/rest/services/Hosted/<service name>/ImageServer"
 } 
}