OptimalPathAsLine

Title  OptimalPathAsLine

Summary

Calculates the optimal path from a source to a destination as a line.


Illustration

Optimal Path As Line tool illustration Optimal Path As Line tool illustration

Usage


Syntax

Parameter Explanation
inputDestinationRasterOrFeatures

An image service or feature service that identifies those locations from which the least-cost path is determined to the least costly source.

If the input is an image service, the input consists of cells that have valid values (zero is a valid value), and the remaining cells must be assigned NoData.

inputDistanceAccumulationRaster

The input distance accumulation raster.

inputBackDirectionRaster

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

For each cell in the back link or direction raster, a value identifies the neighbor that is the next cell on the path from the cell to a source cell.

outputPolylineName

The output feature service that will contain the least cost path.

destinationField (Optional)

The field that will be used to obtain values for the destination locations.

pathType (Optional)

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

  • Best single—For all cells on the input destination data, the least-cost path will be derived from the cell with the minimum of the least-cost paths to source cells.
  • Each zone—For each zone on the input destination data a least-cost path is determined. With this option, the least-cost path for each zone will begin at the cell with the lowest cost distance weighting in the zone. 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 will be treated separately, and a least-cost path will be determined for each from cell.
createNetworkPaths (Optional)

context (Optional)

Code Samples

Optimal Path As Line example 1 (Python window)

The following Python Window script demonstrates how to use the OptimalPathAsLine tool.


import arcpy

arcpy.OptimalPathAsLine_ra(
    "https://myserver/rest/services/destination/ImageServer", 
    "https://myserver/rest/services/accumulationraster/ImageServer", 
    "https://myserver/rest/services/backdirection/ImageServer", 
    "outpath")

                    

Optimal Path As Line example 2 (stand-alone script)

Calculates the optimal path from a source to a destination.


# Name: CalculateDistance_Ex_02.py
# Description: Calculates for each cell the Euclidean distance, direction and allocation
#              to the nearest source.
# Requirements: ArcGIS Image Server

# Import system modules
import arcpy

# Set local variables
inSourceData = 'https://MyPortal.esri.com/server/rest/services/Hosted/reccenter/ImageServer'
outDistanceName = "eucdistance"
maxDistance = "4000"
cellSize = "10"
outDirectionName = "eucdirect"
outAllocationName = "eurallocation"
allocationField = "dataid"


# Execute EucDistance
arcpy.CalculateDistance_ra(inSourceData, outDistanceName, maxDistance, cellSize, outDirectionName,
                           outAllocationName, allocationField)


                    

Tags

Credits

Use limitations