GIS Gradient Example

GIS Gradient Example preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

code example 

Tagged by Reuven M. Lerner over 7 years ago

gis 

Tagged by Reuven M. Lerner over 7 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 1079 times • Downloaded 69 times • Run 4 times
Download the 'GIS Gradient Example' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Click to Run Model

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.

Uploaded by When Description Download
Uri Wilensky over 7 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky almost 8 years ago Updated version tag Download this version
Uri Wilensky almost 9 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 10 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 10 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 10 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 10 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 10 years ago Model from NetLogo distribution Download this version
Uri Wilensky over 10 years ago GIS Gradient Example Download this version
Uri Wilensky over 10 years ago GIS Gradient Example Download this version

Attached files

File Type Description Last updated
GIS Gradient Example.png preview Preview for 'GIS Gradient Example' over 7 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.