Generating Streamlines from Digital Elevation
Models
A common need in many GIS applications is accurate river locations. In many parts of
the world, high quality, and human-checked GIS datasets already exist marking
hydrography already exist, but in some places, this data is still missing or incomplete. In
this lab, we'll go through a workflow to generate streamlines only using a digital elevation
model as our input. To practice this, we'll use the Navarro River Watershed in California
as a case study and generate streamlines within that region. For our data in this
exercise, we'll prefix most outputs with nav to represent that they are for the Navarro
River.
This process will give us a concrete use of an algorithm - a set of steps designed to get
from our inputs to our outputs - and we'll need to chain together many different tools to
get our streamlines from our digital terrain model. This isn't just a formula to memorize,
it's a mental thought process. Consider how each tool gets us closer to our needed result
of streamlines by providing the input for the next tool.
In addition to being its own lesson, this exercise sets up a few future exercises. First,
we'll use the generated streamlines and the intermediate data products to run an
analysis of salmon nests, called redds, and their relationship to the harvest of wood in
the area. Then, in a future exercise, we'll look into how we can use automation to make
the process of generating streamlines easier (more streamlined, you might say).
1. Summary of Steps
This graphic illustrates the approximate process we'll follow in this exercise. To generate streamlines
(the green oval on the right), we'll need to start with our DEM (blue oval on the left).
1. First, we'll generate a flow direction raster, which has pixels indicating the direction water would
flow off of the surface.
2. Then, we'll use that raster to generate a flow accumulation raster, whose values represent how
many cells flow into each cell.
3. Then we'll run a series of tools that extract the highest areas of flow accumulation, which are
effectively the streams, and turn those first into a raster stream network, then a set of
streamlines.
You'll learn how to make diagrams like this that actually run the relevant tools, called models, in another
exercise.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 1
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
Note: All the following procedures are being performed on a depressionless DEM. Prior to initiating any
of these algorithms, it is important to identify and fill any sinks - local low spots that interrupt flow in the
DEM, but that likely aren't on the landscape. Read the documentation about the Sink and Fill tools in
ArcGIS to get more information on this topic.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 2
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
2. Getting Set Up - Add the Spatial Analyst extension
Note: If you already have spatial analyst enabled in ArcMap, you can skip to step 2.
Let's start by making sure Spatial Analyst is enabled. Spatial Analyst is a very powerful ArcGIS tool for
raster processing, making it essential for working with DEMs. It has a built in hydrology toolset that
forms the basis for stream generatiojn from a DEM. It is not enabled by default though, so we'll need to
go through a few steps to enable it. Add the Spatial Analyst Extension by:
1. Select the Customize menu
2. Click Extensions…
3. Check the Spatial Analyst box
4. Select Close.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 3
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 4
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
3. Part 1: Generating streamlines from a DEM
We'll start off with the digital elevation model - add it to your map document. It is a File Geodatabase
raster named nav_dem_10m located in analysis_data.gdb.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 5
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
4. Run Flow Direction
So, as the diagram showed, our first step to creating streamlines is to generate a Flow Direction raster.
Luckily, there's a tool for this in the Spatial Analyst toolbox. Run the tool now.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 6
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
4.1 Setting up Flow Direction
The flow direction tool opens. As was mentioned earlier, this is a raster that is derived from the digital
elevation model where each value in the output represents a direction (North, North-East, etc). The
values are integers, but each integer represents a compass direction. In assigning it colors, we can see
at a glance which way it flows.
1. Right now, we only have one layer in our map document that we can use as input, so use that
as the Input surface raster parameter. Think for a second about the general concept of creating
a flow direction raster and how that can be done from a DEM. Look at the tool help if necessary
and make sure you understand what we're creating here.
2. For the output, place it in your scratch geodatabase (make a geodatabase to fill this role if you
don't have one already), and call it nav_flow_direction_10m
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 7
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
4.2 Technicolor Hillshade
The result of the flow direction tool is a new raster, as seen in the screenshot. I always like to think of it
as a "technicolor hillshade" - the effect of coloring the different flow directions with unique colors is
similar to a hillshade, and you'll probably see that sort of effect in the "shading" created by the color
choice.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 8
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
5. Run Flow Accumulation
The flow accumulation raster is just an intermediate product for us though - a step on our way to getting
streamlines. We need it as input to the next tool, called Flow Accumulation. The Flow Accumulation tool
takes the Flow Direction raster and traverses it like a network. For each cell, it counts up the number of
cells that flow into it - the number of cells upstream - and puts that count in the output raster for that cell.
This is the number of accumulated cells upstream!
Provide the flow direction raster as the input (1), and name yhour output nav_flow_accumulation_10m
(2). Then run the tool.
Thought experiment: How would you figure out the upstream area for a cell based on a flow
accumulation raster?
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 9
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
5.1 Looking at the flow accumulation raster
The flow accumulation raster is, by default, symbolized in a way that makes it hard to see most of it - its
symbology is dark - the opposite of the bright colors of the flow direction raster. Think for a moment
about why it's so dark - look at the low and high values in the color ramp and think about why so many
values are so low in this kind of stream network (look again at the DEM to understand the high and low
points).
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 10
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
6. Building a stream network
Now, let's extract the cells that will build the backbone of the stream network. If stream and rivers are
places where enough water collects to turn into a single flowing unit (instead of just running across the
surface or soaking into the ground), then these locations are represented by areas of higher flow
accumulation. We'll use the Raster Calculator to extract these cells to a new raster for viewing.
6.1 Extracting the cells
Raster Calculator lets us run expressions against rasters to get a new raster back as a result. If we use
boolean logic (true/false), then it gives us a new raster with cells containing values of 0 and 1, where 0
represents cells for which the expression wasn't true and 1 was a place where the expression was true.
In this case, let's define a stream as any place that has an upstream area of 1 square kilometer. If our
DEM has 10m cell sides, then each cell has an area of 100 m2, so we need 10,000 cells in order to get
1,000,000 m2, or 1 square kilometer. So, in raster calculator, this equates to:
"nav_flow_accumulation_10m" > 10000
ArcGIS evaluates this for each cell in nav_flow_accumulation_10m - if the cell's value is greater than
10000, then it evaluates to true and the output raster's value is 1. Otherwise, it's false and the output
raster's value is 0 in that cell.
Let's build the query using the calculator:
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 11
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
1. Double click on nav_flow_accumulation_10m in the Layers and variables section to add it to the
expression box.
2. In the expression box, add > 10000 to the end of the expression so that it reads like the
expression written above.
3. Save the output raster in your scratch geodatabase and name it nav_raster_stream_network
4. Click OK to run the tool.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 12
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
6.2 Look Familiar?
Do these results look familiar yet? While we might be able to convert this raster directly to lines, we'll
continue on processing these data so that we can get streamlines that are nicely segmented for better
future processing.
6.3 The Set Null Tool
OK, so now, instead of making our streams with the raster calculator where we just get a yes/no
response back, let's use the Set Null tool to get back a new raster that preserves the Flow Accumulation
values but turns everything else to nulls so we can just process those values.
To do this, we'll use the Set Null tool (search for it if you don't know where to find it). Open the tool.
1. Put in nav_flow_accumulation_10m as your Input conditional raster.
2. Put Value < 10000 as your Expression. (think about why the inequality is reversed here)
3. Put nav_flow_accumulation_10m as your Input false raster or constant value.
4. Put the output in your scratch geodatabase as nav_stream_network_with_values
Look at the tool description and help and see if you can figure out what we're doing here. What's the
logic? Set Null works similarly to Raster Calculator. We can provide a condition - a logifcal statement
that it evaluates to determine if it should set the values to Null. So, what we're doing is providing our
flow accumulation raster as the raster to be evaluated - the conditional raster. Then, like Raster
Calculator, it evaluates the expression for each cell, and for cells where the expression is true this tool
sets the output value to Null. We then provide the false raster or a constant value (just a number) that is
used when the expression is false. So the output raster has null values where the expression is true,
and in our case preserves the original flow accumulation values when the expression is false (that's why
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 13
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
we reversed the inequality - we want to keep all the values above 10000 and set the values below
10000 as null!).
Bonus Challenge: Can you repeat this step using just the raster calculator? Hint: Look in the right-hand
box for functions you can use in the expression, and check out the tool help!
6.4 Making a new stream raster
OK, now that we have a raster that's just the flow accumulation values that we think are streams, let's
work on converting them to streams. First, we'll use the stream link tool, which will assign unique
segments of stream between confluences (merging) of rivers all the same ID, so each unique raster
value is a different stream segment.
Find and open the stream link tool.
1. Pass in the raster you just created, nav_stream_network_with_values as the Input stream raster
2. Provide nav_flow_direction_10m as the Input flow direction raster
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 14
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
3. Put your output in the scratch geodatabase and name it nav_linked_streams
Run the tool. Once it's done running, explore the result a little bit. We'll use this raster much more in the
future labs, so make sure to keep it around!
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 15
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
6.5 Convert to stream order
Now we'll make a stream order raster. Stream order is a measure of the size of a stream, usually based
on the number of upstream confluences. Read the tool help for more information on how it's calculated.
We'll finally use this to create our streamlines, and then the converted streamlines will have an attribute
denoting the stream size since the raster value will be attached.
1. For Input stream raster pass in nav_stream_network_with_values
2. Provide your flow direction raster again for the second parameter
3. Put the output raster in your scratch geodatabase and name it nav_stream_order
4. Use the default Method of stream ordering (STRAHLER)
Run the tool.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 16
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
6.6 The Strahler Stream Order
Examine the results of the Stream Order tool. Where are higher values, and does there seem to be a
method to how the values change? Look at the Stream Order tool help to find out more information on
how stream orders are assigned.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 17
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
7. Converting to vector
OK! Now we've effectively generated the streamlines, but we're still stuck in raster data. Let's create
vector hydrography by converting our raster to vectore. We'll look at two ways to do this. First, there's
the Raster to Polyline tool, which handles the general case - converting any raster like this to lines.
Then, we'll look at a tool specific to streams, called Stream to Feature. Find the Raster to Polyline tool
and open it up.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 18
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
7.1 Conversion
Raster to Polyline is a straightforward data conversion tool. Provide the input raster you want to convert
- in this case nav_stream_order (1) - and then the field to use to convert it. We'll use the raster's value,
which you can select as Value (2). Put the output in your scratch geodatabase as
nav_streams_raster_to_polyline so that we can distinguish these streams from the others by conversion
method (3). Choose NODATA as the Background value (4), and have it simplify polylines (5). Run the
tool.
7.2 Stream to Feature
Before examining the output, let's convert the streams another way. Find and open the Stream to
Feature tool. This tool has fewer parameters, in part because it's purpose built for converting raster
streams generated using this method to a feature class.
1. Provide nav_stream_order again as your Input stream raster
2. Provide your flow direction raster in the second parameter
3. Put the output in your scratch geodatabase as nav_streams_stream_to_feature
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 19
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
4. Simplify polylines again
Run the tool.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 20
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
7.3 Examine the output
Take a look at the two stream layers you just generated, overlaid on your stream order raster. What is
different about them? Any thought about what is causing them to be different (and related, why we
provided the flow direction raster to Stream to Feature, but not to Raster to Polyline?)
8. Symbolizing our new streams
Open the Symbology properties for the stream layer generated from the Stream to Feature tool
(nav_streams_stream_to_feature). Let's symbolize the streams by stream order in a way that reflects
their size. To do so, we'll use the Graduated symbols symbology style, which increases the size of the
symbol as the quantity increases, rather than changing the color ramp. By doing this, we'll show larger
symbols for larger stream orders.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 21
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
To do this, we'll do many small steps.
1. Switch to the Quantities symbology type.
2. Click Graduated symbols
3. Switch the field to symbolize on to grid_code. This is the value that the streams had in the
raster, so it's the field that contains the stream order designation
4. Confirm that it's using 5 symbol classes. Note the increasing size of the symbols in the symbol
box.
5. Right click on a symbol in the box, and select Properties for All Symbols (6) to bring up the
dialog specifying what the symbols look like.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 22
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
8.1 Make them look like rivers
Let's make these lines look more like rivers - change the color to a blue color (1). Then click OK (2) to
return to the main symbology dialog. Then click OK again to close the main symbology dialog and save
your settings.
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 23
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
9. Take a look at what you built
Let's zoom to the layer to take a look at it. Right click (1) on your new vector hydrography layer
(nav_streams_stream_to_feature) and click Zoom to Layer (2).
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 24
Systems. Copyright 2016 Regents of the University of California
Generating Streamlines from Digital Elevation
Models
9.1 A complete stream network
Take a look at the streams you built. Do they look like you'd expect, in terms of which streams are larger
and which ones are smaller. Do the lines travel in the places you would expect water to flow?
Congratulations on completing this exercise! Save your map document somewhere you can find it, as
you'll use this data again in week 3!
Generating Streamlines from Digital Elevation Models - Coursera Specialization in Geographic Information Page 25
Systems. Copyright 2016 Regents of the University of California