Show Navigation | Hide Navigation
You are here:
Extensions > Spatial Analyst > Spatial Analyst functional reference > Hydrology (Spatial Analyst)

Flow Length

Release 9.3
Last modified September 7, 2011
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Hydrology (Spatial Analyst)"


Related Topics

Calculates distance or weighted distance along a flow path.

Learn more about how Flow Length works


Usage tips

Command line syntax
An overview of the Command Line window
FlowLength_sa <in_flow_direction_raster> <out_raster> {DOWNSTREAM | UPSTREAM} {in_weight_raster}

Parameter Explanation Data Type
<in_flow_direction_raster>

The input raster that records the direction of flow out of each cell.

This can be created with the Flow Direction function.

Composite Geodataset
<out_raster>

The output raster that shows for each cell the upstream or downstream distance along a flow path.

Raster Dataset
{DOWNSTREAM | UPSTREAM}

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
{in_weight_raster}

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 parameters


Command line example

FlowLength_sa C:/data/flowdir C:/data/flowlen DOWNSTREAM

Scripting syntax
About getting started with writing geoprocessing scripts
FlowLength_sa (in_flow_direction_raster, out_raster, direction_measurement, in_weight_raster)

Parameter Explanation Data Type
in_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
out_raster (Required)

The output raster that shows for each cell the upstream or downstream distance along a flow path.

Raster Dataset
direction_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
in_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 parameters


Script 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()

Map Algebra syntax
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)

ArcObjects syntax
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)

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.