Watersheds

The Surface - Watersheds menu selection is enabled when the optional Surface Tools extension has been installed and the focus is on a surface window or on a surface layer in a map window. If you have not activated the Surface Tools extension with a valid Surface Tools serial number you will not be able to use the Surface - Watersheds command.

 

The Watersheds command works with a surface and optionally a drawing to find watersheds in the surface (regions sharing a common drainage) as well as streams in the surface or upstream areas in the surface from points in a specified drawing. Watersheds, streams or upstream areas are shown in a newly-created drawing. The Watersheds dialog thus may be used to accomplish several goals.

 

The Watersheds dialog reports its results by creating one or more new drawings that contain new line or area objects representing streams, watersheds or upstream areas. The line or area objects have data fields in the drawing's table that report useful information, such as the total flow through a particular stream.

 

Streams are line objects that are created in a new drawing. Watersheds and upstream areas are area objects that are created in a new drawing.

 

The new drawings are automatically georegistered to the same coordinate system and location of the surface that was used in the watersheds dialog. They may therefore be immediately overlaid onto the surface as a layer within a map for easy viewing of results.

 

images\dlg_watersheds.gif

 

Launching the Watersheds command in the Surface menu launches the Watersheds dialog. The dialog above uses a surface called Montara Mountain.

 

Controls

 

Name

The name of the newly-created drawing that contains the results.

Description

Optional description for the drawing.

Fill sinks

Smooth out any regions in the surface that would trap water flow without the water flowing to some surface edge. Should almost always be checked even though doing so requires more processing time. Fill sinks is checked by default.

Sources

The name of a drawing that contains points which are to be used for upstream areas or as additional nuclei for watersheds. When a drawing is selected in this combo box, the number of points in the drawing will appear to the right of the box. Drawings with no points will not appear in the list of available drawings.

Min flow

The minimum total amount of water flowing over a region of pixels to consider that region as being a watershed or a stream.

Create streams

Create lines showing streams that are formed by hydrological flow over the surface. When two or more streams intersect, a new stream starts.

Create upstream areas

Given points in the Sources drawing, create areas that flow into each point.

Create watersheds

Create areas that flow into each stream (whether or not streams are also created).

 

Minimum Flow

 

Manifold models watersheds and streams by assuming that one unit of water falls on every pixel in the surface. As water flows downhill from each pixel, the water flowing from a number of different pixels will come together.

 

images\ill_watershed_minflow.gif

 

Consider the illustration above, which shows a very small portion of the Montara Mountain sample surface that has been zoomed in until individual pixels appear as large blocks. The region shown is the bottom of a valley that slopes down to the center and then slopes to the upper right corner of the window.

 

Consider the case where one unit of water falls on each pixel marked with a 1 and then flows to the next pixel in the direction indicated by the blue arrows. As flow is summed up from pixel to pixel the total flow on each blue arrow is indicated by black numbers highlighted with white. For example, the flow down the bottom of the valley starts with values of 1 from each of four pixels to form a flow of 4, which as it goes into the next pixel (which contributes its 1 unit of flow) is joined by a flow from the left with a value of 2 and by a flow from the right with a value of 3 to form a flow of 10,

 

As flows accumulate in this way the end result in the upper right corner is a total flow value of 26 going into the final pixel.

 

Let's assume that the flows from all pixels not marked with a 1 would go to some other direction and not fall into the little valley implied by the blue flow lines. If the Min Flow parameter were set at 26 or less this entire little value would be marked as its own watershed. If the Min Flow value were set at 27 or higher, then the little valley would be combined with whatever is the downstream watershed as part of that downstream watershed.

 

Streams are likewise created based on the total flow they accumulate. Consider the results of different settings of Min Flow when streams are created:

 

images\ill_streams_minflow_20.gif

 

Using a value of 20 for Min Flow means that only those flows with totals greater than 20 will be identified as streams. In the above illustration, we see that only the flow of 21 results in a stream (shown in red).

 

images\ill_streams_minflow_10.gif

 

If we use a value of 10 for Min Flow that creates a slightly longer stream, because the flows for both 10 and 21 qualify as a stream.

 

images\ill_streams_minflow_4.gif

 

Using a value of 4 for Min Flow will result in a larger stream because additional flows with values 4 and 5 will also be part of the stream.

 

From the above it is clear that the Min Flow specifies the minimum number of pixels drained by a watershed or a stream. Each watershed created with a Min Flow value of 100 will contain at least 100 pixels and each stream created with that value will contain the flow from at least 100 pixels.

 

Creating Streams

 

The watersheds dialog can create both streams and watersheds and can do so at the same time. If both are desired it is most efficient to create both at the same time since the same foundation computation must be accomplished in either case with the creation of stream line objects or watershed area objects requiring a relatively small percentage of the computation.

 

To Create Streams for a Surface

 

1. Open a surface and choose Surface - Watersheds.

2. Enter the Name of the drawing that will contain the results. If you do not specify a name Manifold will create a name by default that uses the name of the surface plus the word "Watersheds."

3. Check the Fill sinks box unless bowl-shaped regions are allowed.

4. If streams are to be computed based upon specific point sources in addition to general precipitation over the surface, choose a drawing name in the Sources box that contains those point locations.

5. Specify a Min flow that must be attained by a stream for it to be created. Smaller values will result in many more, smaller streams. Larger values will result in fewer, larger streams.

6. Check the Create streams box and choose OK.

 

Streams will be computed and a new drawing created that contains line objects representing the streams. Each stream segment from a beginning or intersection with another stream segment to the end or next intersection with another stream segment will be created as a separate line object with the following attributes in the drawing's table:

 

ID

The object ID of the created stream line object.

Flow Total

The total flow through this stream line object, including all flow from upstream as well as flow from that object.

Flow

The flow contributed through this stream line object.

Order

Stream order computed using Strahler ordering.

Streams

Stream order computed using Shreve ordering.

Index

A unique identification number for this stream line.

Flows To

The Index number of the stream into which this stream flows.

 

Example

 

Consider a portion of the Montara Mountain example surface, seen as a layer in a map:

 

images\eg_watersheds_01.gif

 

We open the surface, either in a surface window or as the active layer in a map window and then launch the Surface - Watersheds command.

 

images\eg_watersheds_02.gif

 

We choose the name Streams for the results drawing to be created, check the Fill sinks box, choose a Min flow of 500 and check the Create streams box. Press OK.

 

images\eg_watersheds_03.gif

 

The result is a new drawing, called Streams, which contains lines showing streams. We can drag and drop the Streams drawing as a layer in a map window above the surface to see where the streams are located. Note that the streams are, as expected, located where water would drain from higher elevations to lower elevations.

 

images\eg_watersheds_04.gif

 

We can open the Streams drawing in its own window and select one of the stream lines, as seen above.

 

images\eg_watersheds_05.gif

 

If we open the table for the Streams drawing and scroll down to the selected line's record, we can see that the line object has been created with values in the Flow Total, Flow, Order, Streams, Index and Flows To columns.

 

For this particular stream segment, the Flow contributed by the segment is 943 units and the Total Flow of this segment plus all upstream contributions going through this segment is 11064 units. Using Strahler ordering this segment has an order value of 2 (in the Order column) and using Shreve ordering this segment has an order value of 4 (in the Streams

column).

 

The unique Index number of this stream is 62. If we sort the table using the Index column and then select the record with an Index of 67 we will see that the stream with an Index of 62 does indeed Flow To the stream with an Index of 67.

 

Note that every stream will have a value of at least 500 in the Total Flow column, because 500 was the value used for Min flow in the watersheds dialog.

 

Creating Watersheds

 

Creating watersheds is a process directly analogous to creating streams.

 

To Create Watersheds for a Surface

 

1. Open a surface and choose Surface - Watersheds.

2. Enter the Name of the drawing that will contain the results. If you do not specify a name Manifold will create a name by default that uses the name of the surface plus the word "Watersheds."

3. Check the Fill sinks box unless bowl-shaped regions are allowed.

4. If watersheds are to be computed based upon specific point sources in addition to general precipitation over the surface, choose a drawing name in the Sources box that contains those point locations.

5. Specify a Min flow that must be attained by a watershed for it to be created. Smaller values will result in many more, smaller watersheds. Larger values will result in fewer, larger watersheds.

6. Check the Create watersheds box and choose OK.

 

Watersheds will be computed and a new drawing created that contains area objects representing the watersheds. Each watershed comprising a common drainage for a region of pixels will be created as a separate area object with the following attributes in the drawing's table:

 

ID

The object ID of the created watershed area object.

Flow Total

The total flow through this watershed area object, including all flow from upstream as well as flow from that area.

Flow

The flow contributed within this watershed area object.

Order

Watershed order computed using Strahler ordering.

Streams

Watershed order computed using Shreve ordering.

 

Example

 

We can continue the proceeding example, continuing to use a map of the Montara Mountain example surface.

 

images\eg_watersheds_06.gif

 

To create watersheds, we once more click on the surface layer in our map to make it the active layer and once again launch the Surface - Watersheds dialog. We specify the name Watersheds for the drawing to be created, check the Fill sinks box and check the Create watersheds box. Press OK.

 

images\eg_watersheds_07.gif

 

The result is another drawing, containing areas, which we can drag and drop as a layer above the surface layer in our map. Note that some regions of the surface near the edges do not have watershed areas covering them because these regions drain off the edges of the map and do not have at least 500 pixels.

 

images\eg_watersheds_08.gif

 

If we place the Streams layer above the new Watersheds drawing layer we can see that each watershed area is drained by a stream, since both streams and watersheds were created using the same Min flow value of 500.

 

images\eg_watersheds_08a.gif

 

Some watershed areas, such as the area indicated by a red arrow in the illustration above, may not appear to be drained by a stream.

 

images\eg_watersheds_08b.gif

 

However, when zooming far into the display we can see that this watershed area is, in fact, drained by a short stream. The display has been zoomed in so far that it can be seen how the watershed areas have square edged borders where they follow the boundaries between individual pixels in the surface.

 

The stream is short because the area covers terrain that would be drained by several smaller streams that do not aggregate to a total flow of 500 until they come together at the corner of the area into the short stream.

 

images\eg_watersheds_08c.gif

 

If we create streams with a Min flow value of 100 we can see the smaller streams with flow values less than 500 that drain this area. The illustration above shows the smaller streams created with a Min flow value of 100 as blue lines in a layer beneath the Streams drawing layer showing streams created with a Min flow value of 500 as thicker black lines.

 

images\eg_watersheds_09.gif

 

We can zoom back out in our map to see the Streams layer above the Watersheds areas layer, and we can select that watershed area that underlies the stream segment we had selected earlier in this example.

 

images\eg_watersheds_10.gif

 

If we open the table associated with the Watersheds drawing and scroll to the selected record, we can see that the watersheds areas, just like the stream lines, also have values in the Flow Total, Flow, Order, Streams, Index and Flows To columns. In fact, since the watersheds and the streams drawings were both computed using the same Min flow value of 500 we would expect that the flows and other values for the watershed area underlying the stream object would be the same as for the stream object. That is the case

 

The conceptual process here is that a stream segment has a given Flow value which is the water draining into that segment. The watershed for which all flow drains down to the same stream segment will have the same Flow value since it is the same pixels that drain together to define the watershed area and to form the stream.

 

The Flow Total for the stream segment is the flow contributed by all upstream segments that drain into that stream segment, and the Flow Total for this watershed will be the same because it is that flow contributed by all upstream watersheds that drain, through their stream segments, into the stream segment for this watershed.

 

images\eg_watersheds_11.gif

 

To see the effect of a larger Min flow value, we can create watersheds for the surface using a Min flow value of 2000.

 

images\eg_watersheds_12.gif

 

As expected, the result is larger watershed areas.

 

images\eg_watersheds_13.gif

 

We can automatically color the watershed areas using the Drawing - Color command, and also turn on the Streams drawing that was created using a Min flow value of 500.

 

Note how the watershed areas created using a Min flow value of 2000 combine into larger areas the several smaller watershed areas that had been created using a Min flow value of 500. Note that there are now often several streams draining a single watershed area.

 

images\eg_watersheds_14.gif

 

We can use a variety of formats and display characteristics to create useful displays. For example, in the above illustration the opacity of the watersheds drawing has been reduced to 50% so that the shaded surface may be seen from below, to add shaded relief for a better interpretation of the terrain. The streams layer uses black lines.

 

images\eg_watersheds_15.gif

 

In the illustration above the watersheds drawing has been thematically formatted by the value of the Flow Total column so that watersheds with lesser flow are green and those with more flow are blue. The watersheds drawing layer has 50% opacity and the surface underneath is seen in grayscale (no palette) to provide shaded relief. The streams layer uses black lines.

 

Drawings and Streams

 

Drawings that contain points may be used in the Watersheds dialog to specify additional sources of flow emanating from each point. By adjusting the Min flow value we can focus calculations to the stream effects of the flow.

 

images\eg_watersheds_16.gif

 

Consider a drawing that contains three points, shown as yellow and black squares, which is seen as a layer overlaid in a map above the sample Montara Mountain surface. The points may or may not have data attributes (columns) in the drawing's table, as these are not used in watershed calculations. The only characteristic of the points that is used is their locations.

 

images\eg_watersheds_17.gif

 

To calculate streams issuing from points in the drawing we launch the Watersheds dialog and choose the name of the drawing (in this case, the name is "Drawing") in the Sources combo. In addition, we specify a very high value for Min flow so that the only streams that are created are those that issue from the points in the drawing.

 

images\eg_watersheds_18.gif

 

The result created in the drawing name we specified, Streams from Points, is a set of stream objects that show flow emanating from the points in the drawing.

 

Drawings and Upstream Areas

 

The Watersheds dialog can also compute all regions of pixels that drain into a given point and to create area objects covering those regions.

 

images\eg_watersheds_19.gif

 

Consider a different drawing that also contains three points, shown as green and black squares. The drawing is shown in a layer above a drawing of streams (previously created with the Watersheds dialog) and above the sample Montara Mountain surface.

 

For the sake of providing a good illustration, the three points in the new drawing were each created exactly on top of a stream using the Snap to Lines snap capability. When a point is located exactly on top of a stream line we have a guarantee that all regions drained by that stream will be upstream regions to that point. This will result in reasonably large and thus easily visible upstream areas.

 

images\eg_watersheds_20.gif

 

We launch the Watersheds dialog with the above settings. The Min flow parameter is ignored when computing upstream areas since all areas that drain through a particular point are considered part of its upstream area regardless of how great or small the flow through that area.

 

images\eg_watersheds_21.gif

 

The result is a set of three areas showing the regions that flow into each of the three areas.

 

images\eg_watersheds_22.gif

 

If we open the upstream regions drawing's table we can see that each area has the same value for Flow Total and Flow, since none of the areas flow into each other. The Order and Streams values are all zero since there is no flow order when regions do not flow into each other. Each area has a unique Index, but there are zero values in the Flows To column since there is no flow from one area to another.

 

images\eg_watersheds_23.gif

 

Consider a situation where one of the drawing's points is located upstream from another of the drawing's points, as is the case for the two lower points in the illustration above.

 

images\eg_watersheds_24.gif

 

In that case, Manifold will create upstream areas for each of the watersheds that uniquely drain into each of the points.

 

Using the Index and Flow To Columns

 

The Index and Flow To values computed for streams and watersheds allow us to use SQL to make selections in a very flexible way.

 

Suppose we have objects A and B and A flows into B. The objects may be lines (representing streams) or areas (representing watersheds). If the Index of A is 1 and the Index of B is 2, the Flows To value for A will be 2, which is the Index value of B.

 

The following query will select all objects flowing into the object the Index of which is given as a parameter:

 

PARAMETERS [Target] LONG;

SELECT * FROM Watersheds WHERE [Flows To] = [Target];

 

The following query will select all objects flowing into the object the Index of which is given as a parameter as well as all objects flowing into those objects:

 

PARAMETERS [Target] LONG;

SELECT * FROM Watersheds A WHERE [Flows To] = [Target]

OR EXISTS (SELECT * FROM Watersheds B

WHERE A.[Flows To] = B.[Index]

AND B.[Flows To] = [Target]);

 

Note that the above query recursively calls a simpler query. We may construct further levels of "flows into" queries where each subsequent query recursively calling a simpler query. This approach is fine for casual queries; however, for large recursions it would be faster to use a script since scripts in such cases can execute faster than the equivalent SQL query.

 

Scripting Example

 

Suppose we run the Watersheds command to create a drawing called Watersheds that contains watershed areas. We would like to find all watersheds that drain into a given watershed. We open the Watersheds drawing, select an area and then run the following script:

 

Sub Main

 Set dwg = Application.ActiveDocument.ComponentSet("Watersheds")

 Set recs = dwg.OwnedTable.RecordSet

 If dwg.Selection.Count = 1 Then

  ' obtain index of the selected object

' (there should be only one!)

  Set obj = dwg.Selection(0)

  Set rec = recs(recs.ItemByID(obj.ID))

  parent = rec.Data("Index")

  ' recursively select objects flowing into

' the selected object

  SelectObjects recs, parent

 End If

End Sub

 

Sub SelectObjects(recs, parent)

 For Each rec In recs.EqualTo("Flows To", parent)

  If rec.Mask = 0 Then

   rec.Mask = 1

   SelectObjects recs, rec.Data("Index")

  End If

 Next

End Sub

 

This script uses the Index and Flows To fields to select all watersheds that drain into the selected watershed area. It will take some time to complete, potentially a very long time with large drawings and many watershed objects, but it will select all watersheds that drain into the selected watershed area.

 

Note the use of recursion, an elegant intellectual concept that should be understood and used by all programmers, even though it sometimes may seem like magic. Also note that the above script is an example, not code to be given to end users. Code for end users, of course, should do error checking, such as verifying that one and only one area has been selected.

 

Tech Tip: Place Drawing Points on Streams

 

This topic earlier noted that the drawing points used for upstream area examples were all placed on streams to provide more useful illustrations. Why is that the case?

 

images\eg_watersheds_25.gif

 

Consider three points in a drawing layer above the sample Montara Mountain surface where none of the points are on a stream.

 

images\eg_watersheds_26.gif

 

If we run an upstream areas computation using these three points there are no large upstream areas created. If anything, we will have to zoom into the drawing to see the very small upstream areas that are created.

 

images\eg_watersheds_27.gif

 

The reason why such small areas are created is that for most pixels in a surface the flow from only a very small number of other pixels drains through those pixels. Only pixels that lie on streams will have flow from many other pixels going through them.

 

Therefore, if we wish to find which large regions lie upstream of some points that we think lie in a valley served by flow from many other pixels, the first step is to create streams and then next to place our target points on locations on streams using the Snap to Lines snap function.

 

For example, suppose we are analyzing a mountain for different possible layouts of a proposed ski resort and we want to find good locations for the terminal end of a ski lift. This should be a location that is downhill from as many locations as possible (since skiers don't want to struggle uphill to reach the beginning of a ski lift). Because water flows only downhill we can find downhill-only paths by finding streams. We begin our work by creating streams on the mountain, and then we can choose some locations on major streams to see what upstream areas they serve.

 

Filling Sinks

 

Sinks are regions of pixels that all drain together into the interior of the region, for example, such as a bowl-shaped depression in a level part of a surface. Surfaces will often contain sinks that trap water flow. Such regions may be only a few pixels or they may be rather large regions

 

Checking the Fill sinks option will smooth out any sinks in the region. This option is normally checked to avoid creating many small watersheds or to prevent streams from being trapped in lakes or by dams.

 

images\eg_watersheds_28.gif

 

Consider, for example, the Pilarcitos Lake region of the Montara Mountain sample surface, shown in black pixels in the illustration above. Pilarcitos Lake is formed by a dam and is therefore a sink. The dam forms a basin that prevents any natural flow from the lake downstream of the dam. Only flow allowed through the dam sluices can proceed downstream.

 

images\eg_watersheds_29.gif

 

If we create watersheds with a Min flow of 2000 and do not check the Fill sinks box, then all watersheds with flow of 2000 that drain into the sink (the lake) will not be created.

 

images\eg_watersheds_30.gif

 

If we create the same watersheds and do check the Fill sinks box, all watersheds including those that drain into the lake (shown in yellow above) will be created.

 

See Also

 

Surface Tools

Transforming Surfaces