Calculates the optimal path from a source to a destination as a line.
The Optimal Path As Line tool produces an output line feature service that records the least-cost path, or paths, from sources the closest destination defined within the accumulative cost surface or Euclidean distance surface.
If you have destination features, you can convert them to an image service using the Rasterize Features raster function. Use your existing Cost Distance Raster as the Raster input to the rasterization function. This will ensure that the features are properly converted to an image service using the same cell size, extent, and spatial reference.
The NoData values that exist in the Destination Raster are not included as valid values in the function. The value 0 is considered a legitimate value in the destination raster.
Two input image services are needed to run Cost Path As Polyline. How you generate these inputs depends on the type of analysis you want to complete.
The output feature service has an field called DestID that identifies the destination to which each line leads.
Unlike most other Raster Analysis tools, Cost Path As Polyline will ignore the following environment settings: Output Coordinate System, Extent, Cell Size, and Snap Raster. The pattern of the back link raster would be significantly altered if it were resampled or reprojected, resulting in an incorrect path.
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.
|
createNetworkPaths (Optional) |
There is no explanation for this parameter. |
context (Optional) |
There is no explanation for this parameter. |
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)
There are no tags for this item.
There are no credits for this item.
There are no use limitations for this item.