I am working on a model which uses different maps of the same place. I want turtles to have variables associated with the polygon of each map where they are located. I've been able to easily solve this outside NetLogo when the number of maps is reduced (2 or 3).
Let's say I have map A and map B, all of them shapefiles. What I've been doing is creating an intersection of them so I have multiple polygons containing both variables from maps A and B and using the approach from the "GIS General Examples" model in the NetLogo Models Library to create turtles inside these intersections so their variables named the same than the polygon variables are automatically set.
to create-citizens-in-countries
foreach gis:feature-list-of countries-dataset [ this-country ->
gis:create-turtles-inside-polygon this-country citizens num-citizens-to-create [
set shape "person"
; since we included cntry_name as a citizens-own variable,
; if we wanted to we could give each citizen a label
; with their corresponding cntry_name like so:
;; set label cntry_name
]
]
end
However, adding a map C and eventually a map D makes this approach very inconvenient, as the polygons resulting from the intersections become smaller every time and it is necessary to simplify them to avoid problems when NetLogo is charging them.
Then I thought there may be an alternative approach, which I am not sure is viable using the NetLogo GIS extension. I've been looking at the extension documentation and haven't been able to come up with a solution. In natural language, what I would like to achieve, for a map C, with map A and map B already loaded and already used to create turtles is:
load map C and ask each turtle to check in which polygon of map C they are placed, then ask them to set their own variable
turtle-variable-C
the same value than themap-C-polygon-variable
variable of the polygon from map C where they are located.
Can something like this be programmed using the NetLogo GIS extension? If not, can anyone imagine an alternative approach to solve that?
I think you could implement your alternative approach using gis:contains? or gis:contained-by?. You could ask each polygon to ask each turtle whether the polygon contains the turtle, and if so then set the turtle's variable to the polygon's value. It would look something like this for each map:
foreach (gis:feature-list-of polygons-dataset )
[ the-polygon ->
ask turtles with [gis:contains? the-polygon self]
[ set turtle-var (gis:property-value the-polygon poly-variable)]
]
Another trick is to define patch variables to hold the characteristics of the polygons. Patches could have variables such as map-A-var-1 map-B-var-1
etc. Then set these variables using gis:apply-coverage
. Turtles will automatically use the variables of the patch they are on. This essentially turns your polygons into raster variables, so you must use patches small enough for adequately represent the polygons.