gis:create-turtles-inside-polygon
gis:create-turtles-inside-polygon VectorFeature breed n commands
Randomly create “n” turtles of the given breed within the given VectorFeature and for each agent variable (as defined in 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