Calculate Travel Cost

URL:
https://<root>/<serviceName>/RasterAnalysisTools/GPServer/CalculateTravelCost
Methods:
GET
Version Introduced:
10.6

Description

Calculate Travel Cost diagram

The CalculateTravelCost task calculates the cost distance from a single source or set of sources, while accounting for surface distance and horizontal and vertical cost factors.

While the CalculateDistance task is the straight line distance between locations, the travel cost tools explore the movement of a traveler over a landscape. The CalculateTravelCost operation calculates the least accumulative cost distance for each cell to the source over a cost surface, while optionally accounting for the surface distance and the horizontal and vertical factors.

Example applications include the following:

  • Identify the lease expensive route to construct a new road to a proposed school.
  • Connect the best habitat patches for bobcat with wildlife corridors to allow the species to move between the patches.
  • Calculate the actual cost and distance for a proposed road adjusting for the uphill and downhill changes in the landscape.

Request parameters

ParameterDetails

inputSourceRasterOrFeatures

A layer that identifies the locations from or to which the least accumulated cost distance for every output cell location is calculated.

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:

Use dark colors for code blocksCopy
1
2
"inputSourceRasterorFeatures":{"itemID": <portal item ID>}
"inputSourceRasterOrFeature":{"url": <image service layer url>}

Feature input examples:

Use dark colors for code blocksCopy
1
2
3
4
5
//Feature layer URL
"inputSourceRasterOrFeatures":{"url": <feature service layer url>}

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

outputDistanceName

The output distance image service name that will be created.

This calculates, for each cell, the Euclidean distance to the closest source.

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:

Use dark colors for code blocksCopy
1
"outputDistanceName":{"serviceProperties":{"name":"testrasteranalysis"}}

Output raster examples:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
//Output portal item
"outputDistanceName":{"itemId": <portal item id>}

//Output URL
"outputDistanceName":{"url": <image service url>}

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

inputCostRaster

A raster defining the impedance or cost to move planimetrically through each 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.

Examples:

Use dark colors for code blocksCopy
1
2
3
4
5
//Portal item as input raster
"inputCostRaster": {"itemId": <portal item id>}

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

inputSurfaceRaster

A raster defining the elevation values at each cell location.

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:

Use dark colors for code blocksCopy
1
2
3
4
5
//Portal item as input raster
"inputSurfaceRaster": {"itemId": <portal item Id>}

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

maximumDistance

Defines the threshold that the accumulative cost values cannot exceed.

Syntax: This parameter can only be specified as a numerical value.

Example:

Use dark colors for code blocksCopy
1
"maximumDistance": 10000

inputHorizontalRaster

A raster defining the horizontal direction at each 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.

Examples:

Use dark colors for code blocksCopy
1
2
3
4
5
//Portal item as input raster
"inputHorizontalRaster": {"itemId": <portal item Id>}

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

horizontalFactor

Defines the relationship between the horizontal cost factor and the horizontal relative moving angle.

There are several factors with modifiers from which to select that identify a defined horizontal factor graph. Additionally, a table can be used to create a custom graph. The graphs are used to identify the horizontal factor used in calculating the total cost of moving into a neighboring cell.

For each of the factors, a particular selection of characteristic modifiers will apply. See the Horizontal factor additional information section below for specific details on the settings of the factors and how to set the modifiers of the characteristics.

Values: BINARY | FORWARD | LINEAR | INVERSE_LINEAR

Characteristics: Zero factor | Cut angle | Slope | Side value

Syntax: The parameter is a string.

Examples:

Use dark colors for code blocksCopy
1
2
3
"horizontalFactor": "BINARY 1 30"

"horizontalFactor": "LINEAR 1 -60 60 0.02"

inputVerticalRaster

A raster defining the vertical (z) value for each 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.

Examples:

Use dark colors for code blocksCopy
1
2
3
4
5
//Portal item as input raster
"inputVerticalRaster": {"itemId": <portal item id>}

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

verticalFactor

Defines the relationship between the vertical cost factor and the vertical relative moving angle.

There are several factors with modifiers from which to select that identify a defined vertical factor graph. Additionally, a table can be used to create a custom graph. The graphs are used to identify the vertical factor used in calculating the total cost for moving into a neighboring cell.

For each of the factors, a particular selection of characteristic modifiers will apply. See the Vertical factor additional information section below for specific details on the settings of the factors and how to set the modifiers of the characteristics.

Values: BINARY | LINEAR | SYMMETRIC_LINEAR | INVERSE_LINEAR | SYMMETRIC_INVERSE_LINEAR | COS | SEC | COS_SEC | SEC_COS

Characteristics: Zero factor | Low cut angle | High Cut Angle | Slope

Syntax: This parameter is a string.

Examples:

Use dark colors for code blocksCopy
1
2
3
"verticalFactor": "BINARY 1 30"

"verticalFactor": "LINEAR 1 -60 60 0.02"

sourceCostMultiplier

Multiplier to apply to the cost values.

Syntax: This parameter can be specified as a Double value or as a field.

Examples:

Use dark colors for code blocksCopy
1
2
3
4
5
//Double example
"sourceCostMultiplier": 2

//Field example
"sourceCostMultiplier": sourceMult

sourceStartCost

The starting cost from which to begin the cost calculations.

Syntax: This parameter can be specified as a Double value or as a field.

Examples:

Use dark colors for code blocksCopy
1
2
3
4
5
//Double example
"sourceStartCost": 2.7

//Field example
"sourceStartCost": startCost

sourceResistanceRate

This parameter simulates the increase in effort to overcome costs as the accumulative cost increases.

Syntax: This parameter can be specified as a Double value or as a field.

Examples:

Use dark colors for code blocksCopy
1
2
3
4
5
//Double example
"sourceResistanceRate": 10

//Field example
"sourceResistanceRate": ResistanceRate

sourceCapacity

Defines the cost capacity for the traveler for a source.

Syntax: This parameter can be specified as a Double value or as a field.

Examples:

Use dark colors for code blocksCopy
1
2
3
4
5
//Double example
"sourceCapacity": 100

//Field example
"sourceCapacity": Capacity

sourceTravelDirection

Defines the direction of the traveler when applying horizontal and vertical factors, the source resistance rate, and the source starting cost.

Syntax: A string describing the optimization method, which can be one of the following:

  • FROM_SOURCE : The horizontal factor, vertical factor, source resistance rate, and source starting cost will be applied beginning at the input source and moving out to the non-source cells. This is the default.
  • TO_SOURCE : The horizontal factor, vertical factor, source resistance rate, and source starting cost will be applied beginning at each non-source cell and moving back to the input source.

Example:

Use dark colors for code blocksCopy
1
"sourceTravelDirection": "TO_SOURCE"

outputBlacklinkName

The output back link 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:

Use dark colors for code blocksCopy
1
"outputBlacklinkName":{"serviceProperties":{"name":"testrasteranalysis"}}

Output raster examples:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
//Output portal item
"outputBlacklinkName":{"itemId": <portal item id>}

//Output URL
"outputBlacklinkName":{"url": <image service url>}

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

outputAllocationName

The output allocation 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:

Use dark colors for code blocksCopy
1
"outputAllocationName":{"serviceProperties":{"name":"testrasteranalysis"}}

Output raster examples:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
//Output portal item
"outputAllocationName":{"itemId": <portal item Id>}

//Output URL
"outputAllocationName":{"url": <image service URL>}

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

allocationField

A field on the inputSourceRasterOrFeatures layer that holds the values that define each source.

Syntax: This can be an integer or a string field of the source dataset.

Example:

Use dark colors for code blocksCopy
1
"allocationField": Boundary1

context

Contains additional settings that affect task processing. 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 | pjson

Horizontal factor additional information

The following section contains details on the available settings and characteristics of the horizontalFactor parameter.

In the explanations below, two acronyms are used: Horizontal Factor (HF), which defines the horizontal difficulty encountered when moving from one cell to the next, and Horizontal Relative Moving Angle (HRMA), which identifies the angle between the horizontal direction from a cell and the moving direction.

Horizontal factor keywords

KeywordsDescription

BINARY

Indicates that if the HRMA is less than the cut angle, the HF is set to the value associated with the zero factor; otherwise, it is set to infinity.

FORWARD

Establishes that only forward movement is allowed. The HRMA must be greater or equal to 0 and less than 90 degrees (0 <= HRMA < 90). If the HRMA is greater than 0 and less than 45 degrees, the HF for the cell is set to the value associated with the zero factor. If the HRMA is greater than or equal to 45 degrees, the side value modifier value is used. The HF for any HRMA equal to or greater than 90 degrees is set to infinity.

LINEAR

Specifies that the HF is a linear function of the HRMA.

INVERSE_LAYER

Specifies that the HF is an inverse linear function of the HRMA.

Horizontal factor keyword characteristics

CharacteristicsDescription

Zero factor

Establishes the horizontal factor to be used when the HRMA is zero. This factor positions the y-intercept for any of the horizontal factor functions.

Cut angle

Defines the HRMA angle beyond which the HF will be set to infinity.

Slope

Establishes the slope of the straight line used with the LINEAR and INVERSE_LINEAR horizontal factor keywords. The slope is specified as a fraction of rise over run (for example, 45 percent slope is 1/45, which is input as 0.02222).

Side value

Establishes the HF when the HRMA is greater than or equal to 45 degrees and less than 90 degrees when the FORWARD horizontal factor keyword is specified.

Default values

The default values for the horizontal factor characteristics are as follows:

Keywords Zero factor Cut angle Slope Side value


Binary 1.0 45 ~ ~ Forward 0.5 45 (fixed) ~ 1.0 Linear 0.5 181 1/90 ~ Inverse linear 2.0 180 -1/90 ~

Vertical factor additional information

The following section contains details on the available settings and characteristics of the verticalFactor parameter.

In the explanations of the vertical factor keywords below, two acronyms are used: VF stands for vertical factor, which defines the vertical difficulty encountered moving from one cell to the next; and VRMA stands for vertical relative moving angle, which identifies the slope angle between the FROM or processing cell and the TO cell.

Vertical factor keywords

KeywordsDefinitions

BINARY

Specifies that if the VRMA is greater than the low-cut angle and less than the high-cut angle, the VF is set to the value associated with the zero factor; otherwise, it is infinity.

LINEAR

Indicates that the VF is a linear function of the VRMA.

SYMMETRIC_LINEAR

Specifies that the VF is a linear function of th VRMA in either the negative or positive side of the VRMA, respectively, and the two linear functions are symmetrical with respect to the VF (y) axis.

INVERSE_LINEAR

Indicates that the VF is an inverse linear function of the VRMA.

SYMMETRIC_INVERSE_LINEAR

Specifies that the VF is an inverse linear function of the VRMA in either the negative or positive side of the VRMA, respectively, and the two linear functions are symmetrical with the respect to the VF (y) axis.

COS

Identifies the VF as the cosine-based function of the VRMA.

SEC

Identifies the VF as the secant-based function of the VRMA.

COS_SEC

Specifies that the VF is the cosine-based function of the VRMA when the VRMA is negative and the secant-based function of the VRMA when the VRMA is nonnegative.

SEC_COS

Specifies that the VF is the secant-based function of the VRMA when the VRMA is negative and the cosine-based function of the VRMA when the VRMA is negative.

Vertical factor keyword characteristics

CharacteristicDefinition

Zero factor

Establishes the vertical factor used when the VRMA is zero. This factor positions the y-intercept of the specified function. By definition, the zero factor is not applicable to any of the trigonometric vertical functions (COS, SEC, COS-SEC, or SEC-COS). The y-intercept is defined by these functions.

Low cut angle

Defines the VRMA angle below which the VF will be set to infinity.

High cut angle

Defines the VRMA angle above which the VF will be set to infinity.

Slope

Establishes the slope of the straight line used with the LINEAR and INVERSE_LINEAR vertical factor keywords. The slope is specified as a fraction of rise over run (for example, 45 percent slope is 1/45, which is input as 0.02222).

Default values

The default values for the vertical factor characteristics are as follows:

Keyword Zero factor Low cut High cut Slope Power Cos Sec angle angle power power


Binary 1.0 -30 30 ~ ~ ~ ~ Linear 1.0 -90 90 1/90 ~ ~ ~ Symmetric linear 1.0 -90 90 1/90 ~ ~ ~ Inverse linear 1.0 -45 45 -1/45 ~ ~ ~ Symmetric inverse linear 1.0 -45 45 -1/45 ~ ~ ~ Cos ~ -90 90 ~ 1.0 ~ ~ Sec ~ -90 90 ~ 1.0 ~ ~ Cos_sec ~ -90 90 ~ ~ 1.0 1.0 Sec_cos ~ -90 90 ~ ~ 1.0 1.0

Response

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

Use dark colors for code blocksCopy
1
2
3
4
{
  "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:

Use dark colors for code blocksCopy
1
https://<raster analysis tools url>/CalculateTravelCost/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:

Use dark colors for code blocksCopy
1
https://<raster analysis tools url>/CalculateTravelCost/jobs/<jobId>/results/<output parameter>

Example usage

Below is a sample request URL for CalculateTravelCost .

Use dark colors for code blocksCopy
1
https://services.myserver.com/arcgis/rest/services/System/RasterAnalysisTools/GPServer/CalculateTravelCost/submitJob

JSON response syntax

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

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
{
  "paramName": <parameter name>,
  "dataType": "GPString",
  "value": {
    "itemId": <item Id>,
    "url": <URL>
  }
}

JSON Response example

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
{
  "paramName": "outputDistanceRaster",
  "dataType": "GPString",
  "value": {
    "itemId": "f121390b85ef419790479fc75b493efd",
    "url": "https://<server name>/arcgis/rest/services/Hosted/<service name>/ImageServer"
  }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.