Calculates distance or weighted distance along a flow path.
Learn more about how Flow Length works
Usage tips
Command line and Scripting
Map Algebra
ArcObjects
FlowLength_sa (in_flow_direction_raster, out_raster, direction_measurement, in_weight_raster)
| Parameter |
Explanation |
Datatype |
| Input flow direction raster (Required) |
The input raster that records the direction of flow out of each cell.
This can be created with the Flow Direction function.
|
Composite Geodataset |
| Output raster (Required) |
The output raster that shows for each cell the upstream or downstream distance along a flow path.
|
Raster Dataset |
| Direction of measurement (Optional) |
The direction of measurement along the flow path.
- DOWNSTREAM — Calculates the downslope distance along the flow path, from each cell to a sink or outlet on the edge of the raster.
- UPSTREAM — Calculates the longest upslope distance along the flow path, from each cell to the top of the drainage divide.
|
String |
| Input weight raster (Optional) |
The weight to be assigned to each cell.
If no {in_weight_raster} is specified, a default weight of one will be applied to each cell. For each cell in the output raster, the result will be the number of cells that flow into it.
|
Composite Geodataset |
Data types for geoprocessing tool parametersScript Example
# FlowLength_sample.py
# Description:
# Calculates distance, or weighted distance along a flow path.
# Requirements: None
# Author: ESRI
# Date: Sept 6, 2005
# Import system modules
import arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create()
try:
# Set local variables
InFlowDirectionRaster = "C:/data/flowdir"
OutRaster = "C:/data/flowlen"
InDirectionOfMeasurement = "DOWNSTREAM"
# Check out Spatial Analyst extension license
gp.CheckOutExtension("Spatial")
# Process: FlowLength
gp.FlowLength_sa(InFlowDirectionRaster, OutRaster, InDirectionOfMeasurement)
except:
# If an error occurred while running a tool, then print the messages.
print gp.GetMessages()
FlowLength(<dir_grid>, {weight_grid}, {DOWNSTREAM | UPSTREAM})
| Parameter |
Explanation |
| <dir_grid> |
Raster indicating direction of flow.
This raster is created using the FlowDirection function. |
| {weight_grid} |
A raster defining the impedance or resistance to move through each cell.
The value at each cell location represents the cost per unit distance of moving through the cell. Each cell location value is multiplied by the cell resolution to obtain the total cost of passing through the cell. |
| {DOWNSTREAM | UPSTREAM} |
Keyword indicating the direction of measurement along the flow path.
- DOWNSTREAM — Calculates the downslope distance along the flow path from each cell to a sink or outlet on the edge of the raster.
- UPSTREAM — Calculates the longest upslope distance along the flow path from each cell to the top of the drainage divide.
|
Map Algebra example
flowlength(direction)
flowlength(direction, weight, upstream)
IHydrologyOp::FlowLength (directionRaster As IGeoDataset, downStream As Boolean, [weightRaster As Variant]) As IGeoDataset
| Parameter |
Explanation |
| directionRaster |
Raster indicating direction of flow.
This raster is created using the IHydrologyOp::FlowDirection method. |
| downStream |
A Boolean expression indicating the direction of measurement along the flow path.
If True, the method calculates the downslope distance along the flow path from each cell to a sink or outlet on the edge of the raster.
If False, the method calculates the longest upslope distance along the flow path from each cell to the top of the drainage divide. |
| [weightRaster] |
A raster defining the impedance or resistance to move through each cell.
The value at each cell location represents the cost per unit distance of moving through the cell. Each cell location value is multiplied by the cell resolution to obtain the total cost of passing through the cell. The data type for the weightRaster can be any raster object that supports IGeoDataset (for example, Raster, Rasterband, and so on). |
ArcObjects example
' Create the RasterHydrologyOp object
Dim pHydrologyOp As IHydrologyOp
Set pHydrologyOp = New RasterHydrologyOp
' Declare the input direction raster object
Dim pDirectionDataset As IGeoDataset
' Calls function to open a raster dataset from disk
Set pDirectionDataset = OpenRasterDataset("D:\SpatialData", "dirraster")
' Declare the output raster object
Dim pOutputRaster As IGeoDataset
' Calls the method
Set pOutputRaster = pHydrologyOp.FlowLength(pDirectionDataset, True)