ArcGIS REST API

Determine Travel Cost Path as Polyline

Determine Travel Cost Path as Polyline diagram

The Determine Travel Cost Path as Polyline task calculates the least cost path between sources and destinations.

Example applications include the following:

  • Find the best route for a new road in terms of construction costs.

The least-cost way to travel from the source to the destination. This path is the least expensive route relative to the cost units defined by the cost raster

Request URL

http://<raster analysis url>/DetermineTravelCostPathAsPolyline/submitJob

Request Parameters

The following table lists the parameters with syntax and details for each.

ParameterDescription

inputSourceRasterOrFeatures

(Required)

The layer that identifies the cells to determine the least costly path from.

Raster input

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

Domain: Integer raster

Examples:

  • "inputSourceRasterOrFeatures":{"itemID": <portal item id>}
  • "inputSourceRasterOrFeatures":{"url": <image service layer url>}

Feature input

Syntax: This parameter can be specified as one of the following:

  • A URL to a feature service layer
  • A feature collection

Examples:

  • "inputSourceRasterOrFeatures":{"url": <feature service layer url>}
  • "inputSourceRasterOrFeatures":{"layerDefinition": {}, "featureSet": {}}

inputCostRaster

(Required)

A raster defining the impedance or cost to move planimetrically through each cell.

The value at each cell location represents the cost-per-unit distance for moving through the cell. Each cell location value is multiplied by the cell resolution while also compensating for diagonal movement to obtain the total cost of passing through the cell.

The values of the cost raster can be integer or floating point, but they cannot be negative or zero (you cannot have a negative or zero cost).

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

Examples:

  • "inputCostRaster": {"itemId": <portal item id>}
  • "inputCostRaster": {"url": <image service layer url>}

inputDestinationRasterOrFeatures

(Required)

The layer that defines the destinations used to calculate the distance. The layer can be an image service or a feature service.

Raster input

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

Domain: Integer raster

Examples:

  • "inputDestinationRasterOrFeatures":{"itemID": <portal item id>}
  • "inputDestinationRasterOrFeatures":{"url": <image service layer url>}

Feature input

Syntax: This parameter can be specified as one of the following:

  • A URL to a feature service layer
  • A feature collection

Examples:

  • "inputDestinationRasterOrFeatures":{"url": <feature service layer url>}
  • "inputDestinationRasterOrFeatures":{"layerDefinition": {}, "featureSet": {}}

outputPolylineName

(Required)

The task will create a feature service of the results. You define the name of the service.

REST web example: myOutput

REST scripting example: "outputPolylineName" : "myOutput1"

pathType

A keyword defining the manner in which the values and zones on the input destination data will be interpreted in the cost path calculations.

Syntax: A string describing the path type, which can be one of the following:

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

Example:

  • "pathType": "EACH_ZONE"

context

Contains additional settings that affect task execution.

This task has the following settings:

  • Extent (extent)—A bounding box that defines the analysis area.
  • Output Spatial Reference (outSR)—The output raster will be projected into the output spatial reference.
  • Snap Raster (snapRaster)—The output raster will have its cells aligned with the specified snap raster.
  • Cell Size (cellSize)—The output raster will have the resolution specified by cell size.
  • Mask (mask)—Only cells that fall within the analysis mask will be considered in the operation.

f

The response format. The default response format is html.

Values: html | json

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

http://<raster analysis url>/DetermineTravelCostPathstoDestinations/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://<raster analysis url>/jobs/<jobId>/results/featureLayer?token=<your token>&f=json

ParameterDescription

outputPolylineFeatures

This is the output travel cost path polyline item ID and URL.

Example:

{"url": 
"http://<analysis url>/DetermineTravelCostPathAsPolyline/jobs/<jobId>/results/outputDistanceRaster"}

The result has properties for parameter name, data type, and value. The contents of value depend on the outputPolylineName parameter provided in the initial request.

  • If outputPolylineName was provided, value contains the URL to the feature service layer.

    {
    "paramName":"resultLayer", 
    "dataType":"GPString",
    "value":{"url":"<hosted featureservice layer url>"}
    }

  • If outputPolylineName was not provided, value contains a feature collection.

    {
    "paramName":"resultLayer",
    "dataType":"GPString",
    "value":{"layerDefinition": {}, "featureSet": {}}
    }