NetLogo banner

 Contact Us

 Modeling Commons

 User Manuals:


NetLogo User Community Models

(back to the NetLogo User Community Models)


by James Steiner (Submitted: 03/05/2004 )

[screen shot]

Download watershed
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".

(You can also run this model in your browser, but we don't recommend it; details here.)


A terrain generator demo and watershed simulator, with a nifty 3-d terrain visualizer thrown in as a bonus.


The patch "elev" is the hard surface of the terrain. Level is the measure of the current surface level. If the patch is dry, level is the same as elev. If the patch is wet, then level is greater than elev by the depth of the water.

To simulate the flow of water, each "wet" patch compares it's own "level" with the level of it's neighbors. If any neighbor has a lower level, the patch finds one of the neighbors with the very lowest level, figures the difference between the two levels, and shares half of that difference with the low neighbor. In other words, water pours from the patch to it's lowest neighbor to make both patches level. All the water on the high patch could pour into the low patch, if needed.



To get started, click one of the terrain generator buttons. The model comes with river valley and volcano (atoll) generators.


To add water to the river, click the river? switch on.
Water flows from the head of the river.
The head is defined as the point of lowest elevation on the top row. That may not be at the center of the row.

Click on Drain? to contantly remove water from the bottom row.

To make the volcano "erupt" click the erupt? switch on.
Water flows from the center of the volcano. I know, it's silly.

To add water to the entire surface of the terrain (to turn the volcano into an atoll, for example) click the rain, rain-hard, or quick-fill buttons. Rain-hard is 100 X the normal rain-rate. Rain and rain-hard add to the already present water, if any. Quick-fill sets the water depth to be even with the mean elevation of the entire terrain.

To create a flash-flood, click the flood button. The top row gets flooded.

The dry-all button removes all the water from the terrain.


Click the Flow button. The water on the terrain will seek it's own level. Rivers flow, lakes form, dams fill, lava flows, islands emerge from the sea!

3-D Visualization
To see the terrain in 3-D, click the "setup-3d" button.

After that, if you make changes in the terrain, or to see the effects of water flow, click the "render-3d" button to update the display.

To clear the 3-d display, click the clear-3d button.

The animate button continuously refreshes the 3-d display, useful when adjusting the tilt and spin sliders.

The auto-spin switch causes the animate button to continuously changes the spin slider, as well.


The label? siwtch turns on the labeling of the patches with their current water depth.
If altitude? is on, the label shows the actual level, rather than the water depth.

The false-color? switch causes the model to use a different coloring scheme, that exposes the elevations differently.

The altitude? switch alters the way the water is colored.
Altitude? on colors by the surface level of the water.
Altitude? off colors by water depth.


Notice how water flows downhill! I'm a fricken genius!


What conditions will cause the river to overflow it's banks? How do you think this compares to real-world flood conditions?
Import some real terrain data, perhaps from a geographic information system.
Does the model-generated flow match the real-world flows on that terrain?


Add additional terrain generators: cistern, septic field, mountain.

Generate a terrain that has one straight river and one curvy river. Is the flow rate different?
Add the effect of erosion from the passage of water.
Allow for different types of ground (soil, sand, rock, clay) that erodes differently.
Further, allow for each elevation to be a different type of rock so as erosion occors, different layers are exposed, affecting the rate of erosion.
Further, make it so each patch has strata.
Add the ability to track, measure, whatever the direction and velocity of the water flow. Perhaps a turtle on each patch can show the direction that the water flowed, and remember how much water it was. Or perhaps the sliding mean of the directions and amounts.

Then put boats or flotsom in the water, moving with the currents!
The model treats the ground as completely waterproof. However, in the real world, different ground types absorb water differently. Rock, none. Sand, lots! Sandlots! Get it? Anyway, water flows *below* the surface, *through* layers. Expand the model to allow water to flow through permeable surface layers.
Ok, now this is crazy: extend the model to support multiple strata with different permiabilities, including voids, and all water to flow through, around, and between the layers. This would allow for undergound springs, water-tables, and predicting otherwise unexpected run-off behaviors due to water-permeable subsurface layers.
Enhance the 3-D visualizer. It is fairly primitive, and could use the following enhancements:

Z-order clipping: Hide nodes that should be behind other nodes.
Perspective: The current view is an orthagonal projection. Add a perspective projection.
Additional rotations: How about x-axis rotation?
3D detail adjustment: For models with low resolution, the option to add additional nodes between the "real" nodes, so that the 3-d view is smoother. For models with high resolution, the option to reduce the number of 3d nodes to improve performance of the 3-d view


Patch Scheduling:
Because the patches execute code in a particular order, a bias is introduced that tended to make water flow much faster in some directions that in others. To reduce the effect of this bias, which is due to water flowing to adjacent patches in the same order they are executed, the model updates patches randomly. Each time through the "flow" loop, only 1 in 5 patches are updated.


Thanks to Boyce J Baker, who by seeking assistance on a model of his own, got me thinking about the fun of modeling a watershed.

This work is Copyright 2004 James P. Steiner.
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

(back to the NetLogo User Community Models)