GIS Gradient Example
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This model was built to test and demonstrate the functionality of the GIS NetLogo extension.
HOW IT WORKS
This model loads a raster file of surface elevation for a small area near Cincinnati, Ohio. It uses a combination of the gis:convolve
primitive and simple NetLogo code to compute the slope (vertical angle) and aspect (horizontal angle) of the earth surface using the surface elevation data. Then it simulates raindrops flowing downhill over that surface by having turtles constantly reorient themselves in the direction of the aspect while moving forward at a constant rate.
HOW TO USE IT
Press the setup button, then press the go button. You may press any of the "display-..." buttons at any time; they don't affect the functioning of the model.
EXTENDING THE MODEL
It could be interesting to extend the model so that the "raindrop" turtles flow more quickly over steeper terrain. You could also add land cover information, and adjust the speed with which the turtles flow based on the land cover.
RELATED MODELS
The other GIS code example, GIS General Examples, provides a greater variety of examples of how to use the GIS extension.
CREDITS AND REFERENCES
Comments and Questions
extensions [ gis ] globals [ elevation slope aspect ] to setup clear-all set elevation gis:load-dataset "data/local-elevation.asc" gis:set-world-envelope gis:envelope-of elevation let horizontal-gradient gis:convolve elevation 3 3 [ 1 1 1 0 0 0 -1 -1 -1 ] 1 1 let vertical-gradient gis:convolve elevation 3 3 [ 1 0 -1 1 0 -1 1 0 -1 ] 1 1 set slope gis:create-raster gis:width-of elevation gis:height-of elevation gis:envelope-of elevation set aspect gis:create-raster gis:width-of elevation gis:height-of elevation gis:envelope-of elevation let x 0 repeat (gis:width-of slope) [ let y 0 repeat (gis:height-of slope) [ let gx gis:raster-value horizontal-gradient x y let gy gis:raster-value vertical-gradient x y if ((gx <= 0) or (gx >= 0)) and ((gy <= 0) or (gy >= 0)) [ let s sqrt ((gx * gx) + (gy * gy)) gis:set-raster-value slope x y s ifelse (gx != 0) or (gy != 0) [ gis:set-raster-value aspect x y atan gy gx ] [ gis:set-raster-value aspect x y 0 ] ] set y y + 1 ] set x x + 1 ] gis:set-sampling-method aspect "bilinear" ask patches [ sprout 1 [ set color blue let h gis:raster-sample aspect self ifelse h >= -360 [ set heading subtract-headings h 180 ] [ die ] ] ] gis:paint elevation 0 reset-ticks end to go ask turtles [ forward random-normal 0.1 0.1 let h gis:raster-sample aspect self ifelse h >= -360 [ set heading subtract-headings h 180 ] [ die ] ] tick if not any? turtles [ stop ] end ; Public Domain: ; To the extent possible under law, Uri Wilensky has waived all ; copyright and related or neighboring rights to this model.
There are 10 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
GIS Gradient Example.png | preview | Preview for 'GIS Gradient Example' | over 12 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.