Skip To Content ArcGIS for Developers Sign In Dashboard

Optimal Path As Raster

Description

Optimal Path As Raster diagram

The OptimalPathAsRaster task calculates the optimal path from a source to a destination as a raster.

Example applications include the following:

  • Finding the optimal route for a new road
  • Finding the downstream trace from a location

Request parameters

ParameterDetails
inputDestinationRasterOrFeatures

(Required)

A raster or feature dataset that identifies the cells from which the optimal path is determined to the optimum source.

If the input is a raster, it must consist of cells that have valid values (zero is a valid value) for the destinations, and the remaining cells must be assigned NoData.

Syntax: This parameter can have either a raster input or a feature input. For raster input, this parameter can be specified as a portal item ID, a URL to a raster image service layer, a cloud raster dataset, or a shared raster dataset. For feature input, this parameter can be specified as either a URL to a feature service layer or a feature collection.

Raster input examples:

//Portal item as input raster
"inputDestinationRasterOrFeatures":{"itemId": <portal item Id>}

//URL as input raster
"inputDestinationRasterOrFeatures":{"url": <image service layer url>}

Feature input examples:

//Feature layer URL
"inputDestinationRasterOrFeatures":{"url": <feature service layer url>}

//Feature collection
"inputDestinationRasterOrFeatures":{"layerDefinition": {}, "featureSet": {}}

inputDistanceAccumulationRaster

(Required)

Determines the optimal path from the sources to the destinations when a cost back direction raster is used for the direction input.

Syntax: This parameter can be specified as a portal item ID, a URL to a raster image service layer, a cloud raster dataset, or a shared raster dataset.

Examples:

//Portal item as input raster
"inputDistanceAccumulationRaster":{"itemId": <portal item id>}

//URL as input raster
"inputDistanceAccumulationRaster":{"url": <image service layer url>}

inputBackDirectionRaster

(Required)

Determines the path to return to a source via the least-cost path or the optimal path.

For each cell in the back direction, or flow direction raster, a value identifies the neighbor that is the next cell on the path from the cell to a source cell.

Syntax: This parameter can be specified as a portal item ID, a URL to a raster image service layer, a cloud raster dataset, or a shared raster dataset.

Raster input examples:

//Portal item as input raster
"inputBackDirectionRaster":{"itemId": <portal item id>}

//URL as input raster
"inputBackDirectionRaster":{"url": <image service layer url>}

outputRasterName

(Required)

The name of the output image service that will contain the optimal path.

You can specify the name, or you can create an empty service using Portal Admin Sharing API and use the return JSON object as input to this parameter.

Syntax: A JSON object describes the name of the output or the output raster.

Output name example:

"outputRasterName":{"serviceProperties":{"name":"outOptimalRasterPath"}}

Output raster examples:

//Output portal item
"outputRasterName":{"itemId": <portal item id>}

//Output url
"outputRasterName":{"url": <image service url>}

//Output raster layer service
"outputRasterName":{"serviceProperties":
  {"name":"outOptimalRasterPath",
    "serviceUrl":"https://<server name>/server/rest/services/Hosted/outOptimalRasterPath/ImageServer"},
  "itemProperties":{"itemId":"8cfbd3ec25584d0d8f4ec255840d8f4ed23b8ff7c43b","folderId":"sdfwerfbd3ec25584d0d8f4"}
}

destinationField

The field used to obtain values for the destination locations.

The input feature service must contain at least one valid integer field.

Example:

"destinationField": "destinationValue"

pathType

A string describing the path type, which can be EACH_ZONE, BEST_SINGLE, or EACH_CELL.

  • EACH_ZONE—For each zone on the input destination data, an optimal path is determined and saved on the output raster. The optimal path for each zone begins at the cell with the lowest cost distance weighting in the zone. This is the default.
  • BEST_SINGLE—For all cells on the input destination data, the optimal path is derived from the cell with the minimum of the least-cost paths to source cells.
  • EACH_CELL—For each cell with valid values on the input destination data, an optimal path is determined and saved on the output raster. Each cell of the input destination data is treated separately, and a least-cost path is determined for each cell.

Example:

"pathType": "EACH_ZONE"

context

Contains additional settings that affect task execution.

This task does not support analysis environments.

f

The response format. The default response format is html.

Values: html | json | pjson

Response

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

{
  "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, you use the jobId to retrieve the results. To track the status, you can make a request of the following form:

https://<raster analysis tools url>/OptimalPathAsRaster/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>/OptimalPathAsRaster/jobs/<jobId>/results/outputOptimalPathAsRaster

Example usage

Below is a sample request URL for OptimalPathAsRaster.

https://services.myserver.com/arcgis/rest/services/System/RasterAnalysisTools/GPServer/OptimalPathAsRaster/submitJob

JSON response example

The response returns the outputRaster output parameter, which has properties for parameter name, data type, and value. The content of value depends on the outputRasterName parameter being provided in the initial request. If outputRasterName was provided, value contains the URL for the feature service layer. If outputRasterName was not provided, value contains a feature collection.

{
  "paramName": <parameter name>,
  "dataType": "GPString",
  "value": {
    "itemId": <item Id>,
    "url": <URL>
  }
}

JSON response example

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