# Optimal Path As Raster (Map Viewer Classic)

The Optimal Path As Raster tool determines the optimal raster path from destinations to sources.

## Examples

Example applications include the following:

• Find the optimal route for a new road.
• Find the downstream trace from a location.

## Usage notes

Before generating an optimal path, usually one of the following tools is 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 the Input back direction or flow direction raster. You also need to supply an Input distance accumulation raster; the Input distance accumulation raster is not used to determine the path. Whether you use a constant raster or a digital elevation model (DEM), your path will be the same; only an attribute value on your path will vary. The Flow Direction raster function can be used to generate the D8 flow direction raster.

When the input destination data is a raster, the set of destination cells consists of all cells in the Input raster or feature destination data that have valid values. Cells that have NoData values are not included in the source set. The value zero is considered a legitimate destination.

When using feature data for the input destinations, care must be taken with how the output cell size is managed, particularly when it is coarse relative to the detail present in the input. An internal rasterization process using the Feature to Raster tool is applied. 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 your 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.

The values on the output optimal path represent the number of paths at a given location. In many cases, paths follow the same route, leaving a destination and then converging to the same source. For example, a value of one indicates that there is only one optimal path at a given location, while a value of five means at that location there are five optimal paths going through that cell in the study area.

To generate an optimal path, the Extent, Cell size, and Snap Raster environment settings are ignored and the characteristics of the back direction raster are used to calculate the output raster. The pattern of the back direction raster would be seriously altered if it were resampled or snapped, or if the extent was altered.

The parameters for this tool are listed in the following table:

ParameterExplanation
Choose destination raster or features

A raster or feature input identifying the cells from which the optimal path is determined to the optimum source.

If the input is a raster, it must consist of cells that have valid values (zero is a valid value) for the destinations, and the remaining cells must be assigned NoData. The input raster type must be integer.

Destination field

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

Choose distance accumulation raster

The distance accumulation raster that will be used to determine the optimal path from the destinations to the sources.

The distance accumulation raster is usually 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.

Choose back direction or flow direction raster

The 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 back direction raster is usually created with the Distance Accumulation or Distance Allocation tools. In this case the range of values is from 0 degrees to 360 degrees. The value 0 is reserved for the source cells. Due east (right) is 90 degrees, and the values increase clockwise (180 is south, 270 is west, and 360 is north).

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 this parameter.

Path type (optional)

Specifies a keyword that defines how the values and zones in the input destination data will be interpreted in the cost path calculations.

• To Each Zone—For each zone in the input destination data, a least-cost path will be determined. 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 in 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.
• To Each Cell—For each cell with valid values in the input destination data, a least-cost path will be determined. With this option, each cell of the input destination data is treated separately, and a least-cost path is determined for each cell.

Result layer name

You can specify the name of a folder in My Content where the result will be saved using the Save result in drop-down box.

## Environments

Analysis environment settings are additional parameters that affect a tool's results. You can access the tool's analysis environment settings by clicking the gear icon at the top of the tool pane.

This tool honors the following Analysis Environments:

• Output coordinate system—Specifies the coordinate system of the output layer.

## Similar tools and raster functions

The Optimal Path As Raster tool determines the optimal raster path from destinations to sources. Other tools may be useful in solving similar problems.

### Map Viewer Classic analysis tools and raster functions

Use the Optimal Path As Line tool to calculate the optimal paths and create a feature service output.

Optimal Path As Raster is available as a raster function.

### ArcGIS Pro analysis tools and raster functions

The Optimal Path As Raster and the Optimal Path As Line geoprocessing tools are available in the Spatial Analyst and Raster Analysis toolbox.

The Optimal Path As Raster and the Optimal Path As Line geoprocessing tools are available in the Raster Analysis toolbox.

Optimal Path As Raster is available as a raster function.

### ArcGIS Enterprise developers resources

If you are working in the ArcGIS REST API, use the Optimal Path As Line and the Optimal Path As Raster tasks.

If you are working in ArcGIS API for Python, use from the arcgis.raster.analytics module, or use optimal_path_as_raster from the arcgis.raster.functions.gbl module.