ArcGIS REST API

Determine Travel Cost Paths to Destinations

Description

Determine Travel Cost Paths to Destinations diagram

The Determine Travel Cost Paths to Destinations task calculates specific paths between known sources and known destinations.

The least-cost path is one cell wide, and it travels from the destination to the source. This path is guaranteed to be the least expensive route relative to the cost units defined by the original cost raster that was input into the weighted-distance function.

Example applications include the following:

  • Find the best route for a new road in terms of construction costs.
  • Identify the path to take from several suburban locations (sources) to the closest shopping mall (destination).

Request parameters

ParameterDetails
inputDestinationRasterorFeatures

(Required)

The layer that defines the destinations used to calculate the distance. The layer can either be raster or feature layers.

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

inputCostDistanceRaster

(Required)

The cost distance raster used to determine the least-cost path from the destination locations to a source. Typically the CalculateTravelCost task is used to create this 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
"inputCostDistanceRaster":{"itemId": <portal item id>}

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

inputCostBacklinkRaster

(Required)

A raster defining the return to a source via the least-cost path. Typically the CalculateTravelCost task is used to create this 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
"inputCostBacklinkRaster":{"itemId": <portal item id>}

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

outputName

(Required)

The output image service name that will be created.

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:

"outputName":{"serviceProperties":{"name":"testrasteranalysis"}}

Output raster examples:

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

//Output url:
"outputName":{"url": <image service url}

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

destinationField

A field on the inputDestinationRasterOrFeatures layer that holds the values that define each destination.

The value can either be an integer or a string field of the source dataset.

Example:

"destinationField:""Dest1"

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:

  • 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. This is the default.
  • 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.
  • 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.

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.

{
  "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>/DetermineTravelCostPathsToDestinations/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>/DetermineTravelCostPathsToDestinations/jobs/<jobId>/results/outputRaster

Example usage

Below is a sample request URL for DetermineTravelCostPathsToDestinations.

https://services.myserver.com/arcgis/rest/services/System/RasterAnalysisTools/GPServer/DetermineTravelCostPathsToDestinations/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 is always the output raster dataset itemId and the image service URL.

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