Least Cost Path (Intelligence)

Summary

Finds the shortest path between starting points and ending points across a cost surface.

Usage

  • The Input Starting Point and Input Ending Point parameter values must be within the extent of the Input Cost Surface parameter. Points outside the surface extent will return an empty output.

  • Using multiple points as the Input Starting Point value will significantly increase processing time.

  • Using multiple points as the Input Ending Point value may result in more than two output line features.

  • No Data values in the Input Cost Surface parameter are considered barriers, and the resulting path will route around these areas. If a path cannot be found around No Data cells in the cost surface, a solution may not be possible and additional steps must be taken to modify the cost surface.

  • Run the tool with the Input Cost Surface parameter value in a projected coordinate system, such as Universal Transverse Mercator (UTM).

  • The new StartID and DestID fields are added to the Output Path Feature Class parameter. These fields represent the starting point and ending point that the lines travel between.

  • The starting and ending points will be copied to the output location and will contain the name of the Output Path Feature Class value with _start and _end appended.

Parameters

LabelExplanationData Type
Input Cost Surface

The input raster used to determine the cost to travel from starting point to ending point. No Data values cannot be crossed.

Raster Layer
Input Starting Point

The input starting point feature. Multiple start points will significantly increase processing time.

Feature Set
Input Ending Point

The input ending point feature. Multiple end points will increase the number of output lines, as the resulting path will branch into separate paths.

Feature Set
Output Path Feature Class

The output path feature class.

Feature Class
Zero Cost Handled As
(Optional)

Specifies how zero values in the Input Cost Surface parameter will be handled.

  • Small positiveAll zeros will be changed to a small positive value. This will allow the cells to be traversed. This is the default.
  • No dataAll zeros will be changed to null values. The cells will not be traversed and will be avoided.
String

Derived Output

LabelExplanationData Type
Output Start Point

The symbolized starting point.

Feature Class
Output End Point

The symbolized ending point.

Feature Class

arcpy.intelligence.LeastCostPath(in_cost_surface, in_start_point, in_end_point, out_path_feature_class, {handle_zeros})
NameExplanationData Type
in_cost_surface

The input raster used to determine the cost to travel from starting point to ending point. No Data values cannot be crossed.

Raster Layer
in_start_point

The input starting point feature. Multiple start points will significantly increase processing time.

Feature Set
in_end_point

The input ending point feature. Multiple end points will increase the number of output lines, as the resulting path will branch into separate paths.

Feature Set
out_path_feature_class

The output path feature class.

Feature Class
handle_zeros
(Optional)

Specifies how zero values in the in_cost_surface parameter will be handled.

  • SMALL_POSITIVEAll zeros will be changed to a small positive value. This will allow the cells to be traversed. This is the default.
  • NO_DATAAll zeros will be changed to null values. The cells will not be traversed and will be avoided.
String

Derived Output

NameExplanationData Type
out_start_point

The symbolized starting point.

Feature Class
out_end_point

The symbolized ending point.

Feature Class

Code sample

LeastCostPath example 1 (Python window)

The following Python window script demonstrates how to use the LeastCostPath function in immediate mode.

import arcpy
import os
arcpy.LeastCostPath_intelligence(r"c:\workspace\terrain.gdb\mob_cost_surf", 
                                 r"c:\workspace\startinglocation.shp",
                                 r"c:\workspace\endinglocation.shp",
                                 os.path.join(arcpy.env.scratchWorkspace, "bestpath"),
                                 "SMALL_POSITIVE")
LeastCostPath example 2 (stand-alone script)

The following Python script demonstrates how to use the LeastCostPath function in a stand-alone script.

# Name: LeastCostPath_Example2.py
# Description: Generate the least cost path between an input and output point 
#              based on a cost surface.

# Import system modules
import arcpy
import os

# Set local variables
in_cost_surface = r"c:\workspace\terrain.gdb\mob_cost_surf" 
in_start_point = r"c:\workspace\startinglocation.shp" 
in_end_point = r"c:\workspace\endinglocation.shp"
out_path_feature_class = os.path.join(arcpy.env.scratchWorkspace, "bestpath")
handle_zeros = "SMALL_POSITIVE"

# Run LeastCostPath
arcpy.intelligence.LeastCostPath(in_cost_surface, in_start_point, 
                                 in_end_point, out_path_feature_class,
                                 handle_zeros)

# Report status
if arcpy.Exists(out_path_feature_class): 
    print("Path segments {}".format(arcpy.management.GetCount(out_path_feature_class)[0]))
else: 
    print("Empty output")

Environments

This tool does not use any geoprocessing environments.