Available with Spatial Analyst license.
Summary
Creates a raster of flow direction from each cell to its steepest downslope neighbor.
Illustration
Usage
The output of the Flow Direction tool is an integer raster whose values range from 1 to 255. The values for each direction from the center are the following:
For example, if the direction of steepest drop was to the left of the current processing cell, its flow direction would be coded as 16.
If a cell is lower than its eight neighbors, that cell is given the value of its lowest neighbor, and flow is defined toward this cell. If multiple neighbors have the lowest value, the cell is still given this value, but flow is defined with one of the two methods explained below. This is used to filter out one-cell sinks, which are considered noise.
If a cell has the same change in z-value in multiple directions and that cell is part of a sink, the flow direction is referred to as undefined. In such cases, the value for that cell in the output flow direction raster will be the sum of those directions. For example, if the change in z-value is the same both to the right (flow direction = 1) and down (flow direction = 4), the flow direction for that cell is 1 + 4 = 5. Cells with undefined flow direction can be flagged as sinks using the Sink tool.
If a cell has the same change in z-value in multiple directions and is not part of a sink, the flow direction is assigned with a lookup table defining the most likely direction. See Greenlee (1987).
The output drop raster is calculated as the difference in z-value divided by the path length between the cell centers, expressed in percentages. For adjacent cells, this is analogous to the percent slope between cells. Across a flat area, the distance becomes the distance to the nearest cell of lower elevation. The result is a map of percent rise in the path of steepest descent from each cell.
When calculating the drop raster in flat areas, the distance to diagonally adjacent cells (1.41421 * cell size) is approximated by 1.5 * cell size for improved performance.
With the Force all edge cells to flow outward parameter in the default unchecked setting (NORMAL in Python), a cell at the edge of the surface raster will flow toward the inner cell with the steepest drop in z-value. If the drop is less than or equal to zero, the cell will flow out of the surface raster.
See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.
Syntax
FlowDirection (in_surface_raster, {force_flow}, {out_drop_raster})
Parameter | Explanation | Data Type |
in_surface_raster | The input raster representing a continuous surface. | Raster Layer |
force_flow (Optional) | Specifies if edge cells will always flow outward or follow normal flow rules.
| Boolean |
out_drop_raster (Optional) | An optional output drop raster. The drop raster returns the ratio of the maximum change in elevation from each cell along the direction of flow to the path length between centers of cells, expressed in percentages. This output is of floating-point type. | Raster Dataset |
Return Value
Name | Explanation | Data Type |
out_flow_direction_raster | The output raster that shows the flow direction from each cell to its steepest downslope neighbor. This output is of integer type. | Raster |
Code sample
FlowDirection example 1 (Python window)
This example creates a flow direction raster from an input Grid elevation surface raster.
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outFlowDirection = FlowDirection("elevation", "NORMAL")
outFlowDirection.save("C:/sapyexamples/output/outflowdir01")
FlowDirection example 2 (stand-alone script)
This example creates a flow direction raster from an input Grid elevation surface raster.
# Name: FlowDirection_Example.py
# Description: Creates a raster of flow direction from each cell to its
# steepest downslope neighbor.
# 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
inSurfaceRaster = "elevation"
outDropRaster = "C:/sapyexamples/output/dropraster"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute FlowDirection
outFlowDirection = FlowDirection(inSurfaceRaster, "FORCE", outDropRaster)
# Save the output
outFlowDirection.save("C:/sapyexamples/output/outflowdir02")
Environments
Licensing information
- ArcGIS Desktop Basic: Requires Spatial Analyst
- ArcGIS Desktop Standard: Requires Spatial Analyst
- ArcGIS Desktop Advanced: Requires Spatial Analyst