GP service example: Stream network

Complexity: Beginner Data Requirement: ArcGIS Tutorial Data Setup

Folder

StreamNet

Purpose

Creates a stream network from flow and accumulation data.

Services

  • StoweHillshade (map service)
  • StoweStreamNet (geoprocessing service and result map service)

Geoprocessing task

Create Stream Network

Inputs

Minimum upstream drainage area in hectares.

Output

Stream network

Data

Uses digital elevation data (raster) and other data found in the Spatial Analyst tutorial.

Extension

Spatial Analyst

Of note

Uses a result map service to draw the network.

About this example

Corresponding folder

C:\arcgis\ArcTutor\GP Service Examples\StreamNet contains the completed model and data.

About the Create Stream Network task

The primary purpose of the Create Stream Network task is to produce a stream network for cartographic display. Two results are illustrated below, using a hillshade of the study area (the town of Stowe, Vermont) as a basemap. The idea behind this service is to let the user produce several different networks and choose one that suits his or her cartographic needs.

Example outputs of Create Stream Network

The task creates a stream network defined by a minimum area—the smaller the area, the more stream segments are produced. Each stream segment is assigned a stream order value based on the number of upstream stream segments, and this value is used to determine the line thickness to display each stream segment.

The number of stream segments produced depends on the minimum area used. Using an input of 1 hectare, approximately 32,000 stream segments are produced. For 45 hectares, approximately 600 stream segments are produced.

One of the decisions that you make when creating a geoprocessing service is determining the maximum number of records and features that can be returned from the server to the client. The default is 1,000, and you can increase this to billions. However, transporting large numbers of features across the Web is expensive and slow. Whenever you have a service that may output a large number of features, you should consider using a result map service to create a map of the result and let ArcGIS Server transport the map across the Web instead of the features. Because the number of stream segments produced by the Create Stream Network task is dependent on the minimum drainage area and, if you substitute your own data, the size and topography of the study area, this example uses a result map service to draw the results instead of transporting the features across the Web to the client.

Data

Data

The data for this example comes from C:\arcgis\ArcTutor\GP Service Examples\Watershed. This data, in turn, was derived from C:\arcgis\ArcTutor\Spatial Analyst. To learn how the data in the Watershed folder was created, see the Watershed example.

Basemap

The basemap for this example, StoweHillshade.mxd, has only one layer, Hillshade, as illustrated below. The Hillshade layer is drawn with a transparency of 55 percent.

Stowe Hillshade basemap
Stowe hillshade basemap

StoweHillshade.mxd is published as a map service.

Toolbox and map document

The toolbox for the geoprocessing service is StoweStreamNet, and the source map document for the service is StoweStreamNet.mxd. StoweStreamNet.mxd contains two source data layers, Flow Direction (the flowdir raster) and Flow Accumulation (the accumulation raster).

Model

Model overview

The Create Stream Network model is illustrated below. There is one input variable, Minimum upstream area in hectares. This variable is a double and is the minimum drainage area required to create a stream segment. Smaller areas create more stream segments.

The model calculates the number of raster cells for the input area, then uses the Con tool to perform a conditional if-else evaluation on each of the input cells in the Flow Accumulation raster. Since a cell value in the Flow Accumulation raster is the number of upstream cells flowing into the cell, any cell with an upstream area greater than the cutoff is selected. Selected cells form stream segments and are assigned a 1 in the output raster.

The Stream Order tool assigns a numeric order value to a raster representing branches of a linear network, such as the output of the Con tool. In general, streams with a high order have higher water flows, so stream order can be used as a surrogate for stream width. The output of the model is symbolized so that segments with high order values are drawn with thicker lines.

The Stream To Feature tool converts the Stream Order Raster into the output line feature class. This feature class will be drawn by the result map service using symbology defined in the result map service.

Create Stream Network model

Details about the model follow.

Project data

The Flow Accumulation and Flow Direction variables are layers from the source map document, StoweStreamNet.mxd. These variables are termed project data because they are nonparameter input data.

Calculating number of cells for the minimum area

The Flow Accumulation and Flow Direction rasters have projected Vermont State Plane coordinates, with a linear unit of meters. The cell size is 30 by 30 meters. To determine the spatial reference and cell size of a raster, do either one of the following:

  • In the Catalog window, right-click the raster and click Properties.
  • In the ArcMap table of contents, right-click a raster layer, click Properties, then click the Source tab.

The Calculate Value tool divides the input hectares by the size of a cell in hectares (30 x 30 meters = 900 square meters = 0.09 hectares) to yield the number of cells for the minimum upstream area. The parameters for the Calculate Value tool, illustrated below, make use of variable substitution. By placing percent signs (%) around a variable name, the contents of the variable are substituted for the value.

Calculate Value parameters

The Minimum upstream area in hectares variable is a double data type, created as follows:

  1. Right-click on the ModelBuilder canvas and click Create Variable.
  2. On the Create Variable dialog box, choose Double as the data type.
  3. Click OK.
  4. Rename the newly created variable to Minimum upstream area in hectares.
  5. Double-click the variable and enter a default value. For the Stowe area, 45 is a reasonable default.

The Minimum upstream area in hectares variable is a precondition to the execution of Calculate Value. A precondition means that a variable must contain a value before Calculate Value executes. You can set preconditions as follows:

  1. Right-click Calculate Value.
  2. Click Properties.
  3. Click the Preconditions tab.
  4. Check Minimum upstream area in hectares.

    Setting preconditions

Con process

The Con tool performs a conditional if-else evaluation on each of the input cells in the Flow Accumulation raster.

Con tool parameters
Con tool parameters

Note that the expression makes use of variable substitution. In the expression, all cells with a value greater than the minimum number of cells are selected. (The value of a cell in the Flow Accumulation raster is the number of cells flowing into an individual cell.)

The Input true raster or constant value parameter is the value to assign each selected cell and is set to 1. If you are creating this model from scratch, do the following:

  1. Double-click the Con tool.
  2. For the Input true raster or constant value parameter, enter 1.
  3. Click OK.

The Input true raster or constant value model variable is automatically created and connected to the Con tool.

Stream order process

The Stream Order tool calculates a numeric value for cells that represent branches of a stream network. The parameter values for Stream Order are shown below.

Stream Order parameters
Stream Order parameters

The output raster contains the Shreve stream order value for every cell that represents a stream.

Stream to feature process

The Stream To Feature tool creates a shapefile of the stream segments contained in Stream Order Raster.

Stream to Feature parameters
Stream To Feature parameters

Note that the output is written to %scratchworkspace%. This location is the scratch workspace environment that is set and used by ArcGIS Server.

Tool layer

The tool layer in StoweStreamNet.mxd defines the result map symbology. The steps below show how to create the tool layer and appropriate symbology:

  1. In ArcMap, drag the Create Stream Network tool from the StoweStreamNet toolbox into the ArcMap table of contents to create the Create Stream Network tool layer.
  2. Right-click the Create Stream Network tool layer and click Open to open the tool dialog box.
  3. Use 45 (the default) as the minimum area.
  4. Click OK to run the tool. Note that the default symbology for the stream network is a single line.

In the steps below, you will change the symbology to graduated line symbols. Right-click the Stream Network sublayer and click Properties, then click the Symbology tab.

  1. Click Graduated symbols found beneath the Quantities category.
  2. Choose GRID_CODE as the value field.
  3. Click Classify.

Stream Network symbology properties

  1. On the Classification dialog box, choose Manual as the classification method.
  2. You will set up a manual classification with breaks of 100, 250, 500, 750, and 10000. In the Break Values panel, click the last value in the list. This allows you to edit the value. Enter one of the break values, such as 10000. The list refreshes so that the values are sorted.

    Stream network classification Continue editing and setting the break values until the list appears as illustrated below. After setting break values

  3. Click OK.

    The Symbology tab now looks as illustrated below. You may need to reset the color to blue by clicking Template and choosing a suitable blue color.

    After resetting classification
  4. Click OK.

The legend for the Stream Network sublayer displays GRID_CODE as the classification field, which will not make much sense to the user of your service. To change it, click GRID_CODE in the legend, press the F2 key, and change the text to something more descriptive, such as Shreve Order or Stream Order.

Changing the legend

Publishing

StoweHillshade.mxd is published as a map service.

To publish StoweStreamNet.mxd as a geoprocessing service with a result map service, do the following:

  1. In the Catalog window, right-click StoweStreamNet.mxd and click Publish to ArcGIS Server.
  2. Accept all defaults.

Using

To use the services, start ArcMap and add the StoweHillshade map service and the StoweStreamNet geoprocessing service. Do not add the StoweStreamNet map service since this is a result map service and contains the Flow Accumulation and Flow Direction layers, which have nothing to do with results.

ArcMap with services
ArcMap before executing the service
ArcMap after executing the Create Steam Network task
ArcMap after executing the Create Steam Network task

Related Topics


11/18/2013