Watershed (Spatial Analyst)
Summary
Determines the contributing area above a set of cells in a raster.
Usage
-
The value of each watershed will be taken from the value of the source in the input raster or feature pour point data. When the pour point is a raster dataset, the cell values will be used. When the pour point is a point feature dataset, the values will come from the specified field.
-
Better results will be obtained if the Snap Pour Point tool is used beforehand to help locate the pour points to cells of high accumulated flow.
Syntax
| Parameter | Explanation | Data Type |
in_flow_direction_raster |
The input raster that shows the direction of flow out of each cell. The flow direction raster can be created using the Flow Direction tool. | Raster Layer |
in_pour_point_data |
The input pour point locations. For a raster, this represents cells above which the contributing area, or catchment, will be determined. All cells that are not NoData will be used as source cells. For a feature dataset, this represents locations above which the contributing area, or catchment, will be determined. | Raster Layer | Feature Layer |
pour_point_field (Optional) |
Field used to assign values to the pour point locations. If the pour point dataset is a raster, use Value. If the pour point dataset is a feature, use a numeric field. If the field contains floating-point values, they will be truncated into integers. | Field |
Return Value
| Name | Explanation | Data Type |
| out_raster |
The output raster that shows the contributing area. It will be of integer type. | Raster |
Code Sample
This example determines the contributing area for selected pour point locations on a flow direction GRID raster.
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outWatershed = Watershed("flowdir", "pourpoint")
outWatershed.save("C:/sapyexamples/output/outwtrshd01")
This example determines the contributing area for selected pour point locations on a flow direction GRID raster and outputs the watershed as a TIFF raster.
# Name: Watershed_Ex_02.py
# Description: Determines the contributing area above a set of cells in a
# raster.
# Requirements: Spatial Analyst Extension
# Author: ESRI
# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
# Set environment settings
env.workspace = "C:/sapyexamples/data"
# Set local variables
inFlowDirection = "flowdir"
inPourPointData = "pourpoint"
inPourPointField = "VALUE"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute Watershed
outWatershed = Watershed(inFlowDirection, inPourPointData, inPourPointField)
# Save the output
outWatershed.save("C:/sapyexamples/output/outwtrshd02.tif")