Home
Learn NetLogo
What is NetLogo? Tutorial #0 Sample Model Tutorial #1 Models Tutorial #2 Commands Tutorial #3 Procedures
Documentation
NetLogo Dictionary Interface Guide Interface Tab Guide Info Tab Guide Code Tab Guide Programming Guide Transition Guide Preferences Guide Version History
Advanced Tools
Extension Manager Shapes Editor BehaviorSpace System Dynamics HubNet HubNet Authoring Logging Controlling Mathematica Link NetLogo 3D Cluster Computing (HPC)
Extensions
Extensions Guide Arduino Array Bitmap CSV GIS GoGo LevelSpace Matrix Networks Palette Profiler Python Resource Rnd Sound Simple R Table Time Vid View2.5D
FAQ
Home
Learn NetLogo
What is NetLogo? Tutorial #0 Sample Model Tutorial #1 Models Tutorial #2 Commands Tutorial #3 Procedures
Documentation
NetLogo Dictionary Interface Guide Interface Tab Guide Info Tab Guide Code Tab Guide Programming Guide Transition Guide Preferences Guide Version History
Advanced Tools
Extension Manager Shapes Editor BehaviorSpace System Dynamics HubNet HubNet Authoring Logging Controlling Mathematica Link NetLogo 3D Cluster Computing (HPC)
Extensions
Extensions Guide Arduino Array Bitmap CSV GIS GoGo LevelSpace Matrix Networks Palette Profiler Python Resource Rnd Sound Simple R Table Time Vid View2.5D
FAQ
primitive: gis:raster-sample
GIS Extension Dictionary
  • No items found

gis:raster-sample

gis:raster-sample raster-dataset sample-location

Reports the value of the given raster over the given location. The location may be any of the following:

  • A list of length 2, which is taken to represent a point in netlogo space ([xcor ycor]) of the sort reported by location-of Vertex. The raster dataset is sampled at the point of that location.
  • A list of length 4, which is taken to represent an envelope in GIS space, of the sort reported by envelope-of. The raster dataset is sampled over the area of that envelope.
  • A patch, in which case the raster dataset is sampled over the area of the patch.
  • A turtle, in which case the raster dataset is sampled at the location of that turtle.
  • A Vertex, in which case the raster dataset is sampled at the location of that Vertex.

If the requested location is outside the area covered by the raster dataset, this primitive reports the special value representing “not a number”, which is printed by NetLogo as “NaN”. Using the special “not a number” value as an argument to primitives that expect a number may cause an error, but you can test the value reported by this primitive to filter out “not a number” values. A value that is not a number will be neither less than nor greater than a number value, so you can detect “not a number” values using the following:

let value gis:raster-sample dataset turtle 0
; set color to blue if value is a number, red if value is "not a number"
ifelse (value <= 0) or (value >= 0)
[ set color blue ]
[ set color red ]

If the requested location is a point, the sample is always computed using the method set by set-sampling-method. If the requested location is an area (i.e., an envelope or patch), the sample is computed by taking the average of all raster cells covered by the requested area.

Take me to the full GIS Extension Dictionary.

GIS Extension Dictionary: random-point-inside

Documentation for the random-point-inside primitive.

GIS Extension Dictionary: raster-value

Documentation for the raster-value primitive.


NetLogo is a programmable modeling environment for simulating natural and social phenomena. It was authored by Uri Wilensky in 1999 and has been in continuous development ever since at the Center for Connected Learning and Computer-Based Modeling.

Related Links
  • NetLogo Home
  • CCL Home
  • NetLogo Web
  • NetTango Web
  • NetLogo 3D
  • BehaviorSearch
  • Contact Us

Copyright © 1999-2025 Uri Wilensky and the Center for Connected Learning and Computer-Based Modeling at Northwestern University . All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License , or (at your option) any later version.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at netlogo-commercial-admin@ccl.northwestern.edu .

For more information, visit the NetLogo website .