Calculates the least-cost path from a source to a destination as a line feature.
The Cost Path As Polyline tool produces an output polyline 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. |
inputCostDistanceRaster |
The cost distance or Euclidean distance raster to be used to determine the least-cost path from the sources to the destinations. |
inputCostBacklinkRaster |
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. |
pathType (Optional) |
Specifies the manner in which the values and zones on the input destination data will be interpreted in the cost path calculations.
|
destinationField (Optional) |
The field that will be used to obtain values for the destination locations. |
CostPathAsPolyline example 1 (Python window)
The following Python Window script demonstrates how to use the CostPathAsPoyline function.
import arcpy arcpy.CostPathAsPolyline_ra( "https://myserver/rest/services/destination/ImageServer", "https://myserver/rest/services/costsurface/ImageServer", "https://myserver/rest/services/direction/ImageServer", "outpath", "BEST_SINGLE")
CostPathAsPolyline example 2 (stand-alone script)
Calculates the least-cost path from a source to a destination.
#------------------------------------------------------------------------------- # Name: CostPathAsPolyline_Ex_02.py # Description: Calculates the least-cost path from a source to a destination. # Requirements: ArcGIS Image Server # Import system modules import arcpy # Set local variables inputDestinationLayer = 'https://MyPortal.esri.com/server/rest/services/Hosted/destination/ImageServer' inputCostLayer = 'https://MyPortal.esri.com/server/rest/services/Hosted/costraster/ImageServer' inputDirectionLayer = 'https://MyPortal.esri.com/server/rest/services/Hosted/direction/ImageServer' outputName = 'outTravelPaths' pathType = 'BEST_SINGLE' arcpy.CostPathAsPolyline_ra(inputDestinationLayer, inputCostLayer, inputDirectionLayer, outputName, pathType)
There are no tags for this item.
There are no credits for this item.
There are no use limitations for this item.