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:create-turtles-inside-polygon
GIS Extension Dictionary
  • No items found

gis:create-turtles-inside-polygon

gis:create-turtles-inside-polygon vector-feature breed n commands

Randomly create “n” turtles of the given breed within the given VectorFeature and for each agent variable (as defined in <breeds>-own), if there is a property with the same name in the dataset, set that variable’s value to be the value of that property. Finally, execute any commands in the optional command block. To use generic turtles as the chosen breed, simply supply turtles as the breed argument.

Property names and variable names are compared case-insensitively. Keep in mind that when importing shapefiles, property names may be modified for backwards compatibility reasons. The names given by gis:property-names can always be trusted as authoritative. For manually specifying a mapping between property names and variable names, see the create-turtles-inside-polygon-manual primitive.

Built-in variables such as “label” and “heading” are supported. NetLogo color numeric representations are supported for setting “color” and “label-color”, as well as the 15 default color string representations (“red”, “blue”, “black”, etc.).

As an example: say you had a VectorDataset of polygons representing different zip codes within a state and you want to create 100 different turtles within each zip code and have each turtle know which zip code it originated in. The VectorDataset has a field named “zip”, so you should add a variable named “zip” to the turtles with turtles-own. Then, loop through each VectorFeature in the VectorDataset and use the create-turtles-inside-polygon primitive to create 100 new turtles.

extensions [gis]
globals
[dataset]
turtles-own
[zip]

to
setup
set dataset gis:load-dataset "dataset.shp"
gis:set-world-envelope envelope-of dataset
gis:set-drawing-color red
gis:draw dataset 1

foreach gis:feature-list-of dataset [ this-vector-feature ->
gis:create-turtles-inside this-vector-feature turtles 100 [
set shape "person"
]
]
end

Take me to the full GIS Extension Dictionary.

GIS Extension Dictionary: create-turtles-from-points-manual

Documentation for the create-turtles-from-points-manual primitive.

GIS Extension Dictionary: create-turtles-inside-polygon-manual

Documentation for the create-turtles-inside-polygon-manual 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 .