The Optimal Path as Line tool calculates the path from destinations to the optimal source as a line.
The output is a hosted feature layer.
Learn how Optimal Path as Line works
Examples
Example applications include the following:
Find the best route for a new road in terms of construction costs.
Find the best sailing route between a current location and a destination.
Usage notes
To create paths that cross the edge of the projection, the rasters used as inputs for the Input Distance Accumulation Raster and Input Back Direction Raster parameters must have been created at the full global extent, in either a cylindrical projection or a geographic output coordinate system, while using the Geodesic option for the Distance Method parameter.
Optimal Path as Line includes configurations for input layers, path settings, and the result layer.
Input layers
The Input layers group includes the following parameters:
Input destination raster or features is an integer raster or feature layer that identifies the destination from which the distance is calculated to the least costly source.
You can choose a layer using the Layer button, or use the Draw input features button to create a sketch layer to use as the input. For feature inputs, a count of features is displayed below the layer name. The count includes all features in the layer, except features that have been removed using a filter. Environment settings, such as Processing extent, are not reflected in the feature count.
If a destination falls on NoData in any of the corresponding input rasters, it is ignored in the analysis, and no path from this destination will be calculated.
If the input is a raster, it must consist of cells that have valid values (zero is a valid value) for the destination, and the remaining cells must be assigned NoData.
If the input is a feature layer, it can be point, line, or polygon.
When the input destination data is a feature, the source locations are converted internally to a raster before performing the analysis.
To generate an optimal path, the Cell size environment setting is ignored and the cell size of the Input back direction raster value is used to calculate the output raster. The pattern of the back link raster will be altered if it is resampled to a different resolution. To avoid confusion, do not set the cell size when using this tool.
When using polygon feature data for the input feature destinations, care must be taken with how the output cell size is handled, particularly when it is coarse relative to the detail present in the input. An internal rasterization process using the Polygon to Raster tool is applied, with a default setting for Cell assignment type of Cell center. This means that data that is not located at the center of the cell will not be included in the intermediate rasterized destination output and will not be represented in the distance calculations. For example, if the destinations are a series of small polygons, such as building footprints, that are small relative to the output cell size, it is possible that only a few of them will fall under the centers of the output raster cells, seemingly causing many of the others to be lost in the analysis.
To avoid this situation, as an intermediate step, you can rasterize the input features directly using the Convert Feature to Raster tool and set the Value Field parameter. Then use the resulting output as input to the distance tool you want to use.
Before generating an optimal path, one of the following tools is typically used to create a distance accumulation raster and a back direction raster: Distance Accumulation or Distance Allocation. These are required inputs to generate an optimal path.
The optimal path created can be a flow path based on D8 flow direction. To generate an optimal path in this way, use a D8 flow direction raster as input for Input back direction raster or a flow direction raster. Also supply an Input distance accumulation raster value. If the Create network paths parameter is not available, the Input distance accumulation raster value is not used to determine the path. Whether you use a constant raster or a digital elevation model (DEM), the path will be the same; only an attribute value on the path will vary. However, if Create network paths is available and used, the Input distance accumulation raster value must be an Output flow accumulation raster value. See the Flow Direction tool documentation for more information about D8 flow direction rasters and the Flow Accumulation tool documentation to create the accumulation raster.
Destination field is an integer field that will be used to obtain values for the destination locations.
Input distance accumulation raster is used to determine the optimal path from the sources to the destinations
The distance accumulation raster is typically created with the Distance Accumulation or Distance Allocation tool. Each cell in the distance accumulation raster represents the minimum accumulative cost distance over a surface from each cell to a set of source cells.
Input back direction raster contains calculated directions in degrees. The direction identifies the next cell along the optimal path back to the least accumulative cost source while avoiding barriers.
The range of values is from 0 degrees to 360 degrees, with 0 reserved for the source cells. Due east (right) is 90, and the values increase clockwise (180 is south, 270 is west, and 360 is north).
Path settings
The Path settings group includes the following parameters:
Path type defines how the values and zones on the input destination data will be interpreted in the cost path calculations.
Each zone—For each zone on the input destination data, a least-cost path will be 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. This is the default.
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 cell—For each cell with valid values on the input destination data, a least-cost path will be 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.
Create network paths specifies whether complete, and possibly overlapping, paths from the destinations to the sources will be created or nonoverlapping network paths will be created.
- Unchecked—Complete paths from the destinations to the sources, which can be overlapping, will be created. This is the default.
- Checked—Nonoverlapping network paths will be created.
Result layer
The Result layer group includes the following parameters:
Output line name is the name of the layer that will be created and added to the map.
The name must be unique. If a layer with the same name already exists in your organization, the tool will fail and you will be prompted to use a different name.
- Save in folder specifies the name of a folder in My content where the result will be saved.
Environments
Analysis environment settings are additional parameters that affect a tool's results. You can access the tool's analysis environment settings from the Environment settings parameter group.
This tool honors the Output coordinate system analysis environment.
Outputs
This tool produces a hosted feature layer with optimal paths as line features as output.
The output polyline feature includes a DestID field and a PathCost field. The DestID field identifies the destination to which each line leads. The PathCost field shows the total accumulative cost for each path. If the output is written to a file geodatabase, a shape_length field that contains the total length of the least-cost path is also included.
Usage requirements
This tool requires the following user type and configurations:
Resources
Use the following resources to learn more:
- How Optimal Path as Line works
- Optimal Path As Line in ArcGIS REST API
- optimal_path_as_line in ArcGIS API for Python
- Optimal Path As Line in ArcGIS Pro with the Raster Analysis extension
- Optimal Path As Line in ArcGIS Pro with the Spatial Analyst extension