# Flow Distance (Spatial Analyst)

## Summary

Computes, for each cell, the horizontal or vertical component of downslope distance, following the flow paths, to cells on a stream into which they flow. In case of multiple flow paths, minimum, weighted mean, or maximum flow distance can be computed.

If an optional flow direction raster is provided, the down slope direction(s) will be limited to those defined by the input flow direction raster.

## Illustration ## Usage

• To limit downslope directions along which flow distance is measured, provide an optional input flow direction raster that can be derived using the Flow Direction tool. Choose from D8, D-Infinity (DINF) and multi flow direction (MFD) flow models while generating an optional input flow direction raster. Use the Input flow direction type to specify which method was used when the flow direction raster was created.

• If an optional input flow direction raster is provided, it is recommended that this raster be created using the Flow Direction tool using the same input surface raster that you'll provide to the Flow Distance tool.

If this input surface raster is void of sinks, the distance measurements would be to stream cells represented by the input stream raster.

If this input surface raster has sinks present, some flow paths can get terminated short by them flowing into sinks before reaching streams. In such cases, flow distance measurements for these cells are calculated only up to the sink cells into which they flow.

• When the tool is run without providing an optional flow direction raster, flow distance is assessed considering all possible downslope flow paths from each cell to cell(s) on the stream into which they flow.

When the tool is run with an optional D8 flow direction raster, there is only one possible downslope flow path from every cell to a cell on the stream and flow distance is measured along this single flow path.

• When multiple flow paths exist from each cell to cells on the stream into which they flow, use the Statistics type to compute minimum, weighted mean, or maximum flow distance.

If there is only a single flow path from each cell to a cell on the stream, all statistics types produce the same result.

• It is recommended to create the input stream raster using the same input surface raster that is provided as input to the tool. You can create stream rasters from an input surface raster using the Flow Direction, Flow Accumulation, and Con tools, respectively. If you want to use streams from other data sources, for best results, you would have to burn them into the input surface raster first and then run the Flow Distance tool on the result.

• This tool supports parallel processing. If your computer has multiple processors or processors with multiple cores, better performance may be achieved, particularly on larger datasets. The Parallel processing with Spatial Analyst help topic includes details on this capability and how to configure it.

When using parallel processing, temporary data will be written to manage the data chunks being processed. The default temp folder location will be on your local C: drive. You can control the location of this folder by setting up a system environment variable named TempFolders and specifying the path to a folder to use (for example, E:\RasterCache). If you have administrator privileges on your machine, you can also use a registry key (for example, [HKEY_CURRENT_USER\SOFTWARE\ESRI\ArcGISPro\Raster]).

By default, this tool will use 50 percent of the available cores. If the input data is smaller than 5,000 by 5,000 cells in size, fewer cores might be used. You can control the number of cores the tool uses with the Parallel processing factor environment.

• See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

## Parameters

 Label Explanation Data Type Input stream raster An input stream raster that represents a linear stream network. Raster Layer Input surface raster The input raster representing a continuous surface. Raster Layer Input flow direction raster(Optional) The input raster that shows the direction of flow out of each cell.When a flow direction raster is provided, the down slope direction(s) will be limited to those defined by the input flow directions.The flow direction raster can be created using the Flow Direction tool. The flow direction raster can be created using the D8, Multiple Flow Direction (MFD), or D-Infinity method. Use the Input flow direction type parameter to specify the method used when the flow direction raster was created. Raster Layer Distance type(Optional) Determines if the vertical or horizontal component of flow distance is calculated.Vertical—The flow distance calculations represent the vertical component of flow distance, following the flow path, from each cell in the domain to cell(s) on the stream into which they flow. This is the default.Horizontal—The flow distance calculations represent the horizontal component of flow distance, following the flow path, from each cell in the domain to cell(s) on the stream into which they flow. String Input flow direction type(Optional) Specifies the input flow direction raster type.D8—The input flow direction raster is of type D8. This is the default.MFD—The input flow direction raster is of type Multi Flow Direction (MFD).DINF—The input flow direction raster is of type D-Infinity (DINF). String Statistics type(Optional) Determines the statistics type used to compute flow distance over multiple flow paths. If there is only a single flow path from each cell to a cell on the stream, all statistics types produce the same result.Minimum—Where multiple flow paths exist, minimum flow distance in computed. This is the default.Weighted Mean—Where multiple flow paths exist, a weighted mean of flow distance is computed. Flow proportion from a cell to its downstream neighboring cells are used as weights for computing weighted mean.Maximum—When multiple flow paths exist, maximum flow distance is computed. String

### Return Value

 Label Explanation Data Type Output raster The output flow distance raster. Raster

`FlowDistance(in_stream_raster, in_surface_raster, {in_flow_direction_raster}, {distance_type}, {flow_direction_type}, {statistics_type})`
 Name Explanation Data Type in_stream_raster An input stream raster that represents a linear stream network. Raster Layer in_surface_raster The input raster representing a continuous surface. Raster Layer in_flow_direction_raster(Optional) The input raster that shows the direction of flow out of each cell.When a flow direction raster is provided, the down slope direction(s) will be limited to those defined by the input flow directions.The flow direction raster can be created using the Flow Direction tool. The flow direction raster can be created using the D8, Multiple Flow Direction (MFD), or D-Infinity method. Use the flow_direction_type parameter to specify the method used when the flow direction raster was created. Raster Layer distance_type(Optional) Determines if the vertical or horizontal component of flow distance is calculated.VERTICAL—The flow distance calculations represent the vertical component of flow distance, following the flow path, from each cell in the domain to cell(s) on the stream into which they flow. This is the default.HORIZONTAL—The flow distance calculations represent the horizontal component of flow distance, following the flow path, from each cell in the domain to cell(s) on the stream into which they flow. String flow_direction_type(Optional) Specifies the input flow direction raster type.D8—The input flow direction raster is of type D8. This is the default.MFD—The input flow direction raster is of type Multi Flow Direction (MFD).DINF—The input flow direction raster is of type D-Infinity (DINF). String statistics_type(Optional) Determines the statistics type used to compute flow distance over multiple flow paths. If there is only a single flow path from each cell to a cell on the stream, all statistics types produce the same result.MINIMUM—Where multiple flow paths exist, minimum flow distance in computed. This is the default.WEIGHTED_MEAN—Where multiple flow paths exist, a weighted mean of flow distance is computed. Flow proportion from a cell to its downstream neighboring cells are used as weights for computing weighted mean.MAXIMUM—When multiple flow paths exist, maximum flow distance is computed. String

### Return Value

 Name Explanation Data Type out_raster The output flow distance raster. Raster

### Code sample

FlowDistance example 1 (Python window)

This example creates a flow distance raster.

``````import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outFlowDistance = FlowDistance("streams", "elevation", "", "VERTICAL")
outFlowDistance.save("C:/sapyexamples/output/outflowdist01")``````
FlowDistance example 2 (stand-alone script)

This example creates a flow distance raster.

``````# Name: FlowDistance_Example.py
# Description: Creates a raster of horizontal flow distance from each cell to a cell
# on the stream into which it drains.
# Requirements: Spatial Analyst Extension

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Set environment settings
env.workspace = "C:/sapyexamples/data"

# Set local variables
inStreamRaster = "streams"
inSurfaceRaster = "elevation"
inFlowDirectionRaster = "flowdir"

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Execute FlowDistance
outFlowDistance = FlowDistance(inStreamRaster, inSurfaceRaster, inFlowDirectionRaster, "HORIZONTAL")

# Save the output
outFlowDistance.save("C:/sapyexamples/output/outflowdist02")``````

## Licensing information

• Basic: Requires Spatial Analyst
• Standard: Requires Spatial Analyst