Cost Path function

Available with Spatial Analyst license.


Calculates the least-cost path from a source to a destination.


This function is deprecated and will be removed in a future release.

The Optimal Path As Raster function provides enhanced functionality or performance.

This function produces an output raster that records the least-cost path or paths from selected locations to the closest source cell defined within the accumulative cost surface, in terms of cost distance.

This is a global raster function.


One or more of the weighted cost functions (Distance Accumulation, Cost Distance, Cost Allocation or Cost Back Link) are generally required to be run prior to running the Cost Path function to create the input cost distance and back link rasters. These are mandatory input raster layers to the Cost Path function.

Each least-cost path is assigned a value when encountered in the scanning process. The ending cell on the original source raster layer (from which the cost distance and back link were derived) of a cost path receives one, the first path receives three, the second four, and so on. The value two is reserved for the merged portion of paths that have portions of a common cost path.

The input destination data must be a raster layer. The set of destination cells consists of all cells in the input raster that have valid values. Cells that have NoData values are not included in the set. The value zero is considered a legitimate destination. A destination raster can be created using the extraction tools.

If you have destination or source features, you can convert them to raster using the Rasterize Features function. Use the cost distance or cost back link raster as the Raster input to the rasterization function. This will ensure the feature is rasterized using the same cell size, extent, and spatial reference as the other rasters going into the Cost Path function.

When multiple paths merge and follow the remaining distance back to a source on the same route, the segment where the two paths travel together is assigned the value 2. The merged portion of the path cannot be assigned the value of one of the paths, since the merged portion belongs to both routes.

The Cost Path function can also be used to derive the path of least resistance down a digital elevation model (DEM). In this case, use the DEM for the input cost distance raster and the output from the Flow Direction function for the Cost Backlink Raster.


The Cost Path function parameters are described in the following table:


Destination Raster


A raster dataset layer that identifies those cells from which the least-cost path is determined to the least costly source.

The input raster layer consists of cells that have valid values (zero is a valid value), and the remaining cells must be assigned NoData.

Destination Field

The field used to obtain values for the destination locations. Input feature data must contain at least one valid field.

Cost Distance Raster

The name of a cost distance raster to be used to determine the least-cost path from the destination locations to a source.

The cost distance raster is usually created with the Cost Distance, Cost Allocation, or Cost Back Link function. The cost distance raster layer stores, for each cell, the minimum accumulative cost distance over a cost surface from each cell to a set of source cells.

Cost Backlink Raster

The name of a cost backlink raster layer used to determine the path to return to a source via the least-cost path.

For each cell in the backlink raster, a value identifies the neighbor that's the next cell on the least accumulative cost path from the cell to a single source cell or set of source cells.

Path Type

A keyword defining the manner in which the values and zones on the input destination data will be interpreted in the cost path calculations. The options are as follows:

  • 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 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.
  • 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.

Force flow direction convention for backlink raster

Forces the function to treat the input backlink raster as a flow direction raster. Flow direction rasters can have integer with values from 0-255.

  • Unchecked—If the values of the of the specified backlink raster are integers in the range of 0-8, the dataset will be treated as a cost backlink raster. If the values are from 0-255, the input will be treated as a flow direction raster. If the values are from 0-360 and floating point, the input will be treated as a back direction raster.
  • Checked—The raster supplied for the backlink raster will be treated as a flow direction raster. Use this option of the flow direction raster happens to have a maximum value of 8 or less.

Environment settings

Geoprocessing environment settings for global functions are controlled at the application level. Setting processing environments in ArcGIS Pro can be done by clicking the Environments button on the Analysis tab. See Analysis environments and Spatial Analyst for additional details on environment settings.

The following environments are supported by this global function:

Related topics