Thursday, November 19, 2015

Using Shapefiles in NetLogo

Carrying on with the theme of linking GIS to NetLogo for creating agent-based models. We would like to showcase two simple models. Both are based on using a shapefile to create Schelling-inspired segregation model.

In the first model (as shown in the movie below) we use the polygons to be individual agents. In this example, we import a shapefile where each polygon is either a red or blue agent; or unoccupied (grey). The agent evaluates its neighborhood (i.e. surrounding polygons) and if dissatisfied with its neighborhood moves to an unoccupied polygon. More information  about the model and simple tutorial can be found here and the code and data can be downloaded from here.

In the second example (as shown in the movie below), we use attributes from the shapefile to add a specific number of agents to each polygon and again, the agents move if they are dissatisfied  with their current location. This is calculated by the agents examining both their geometrical neighboring polygons; and their 8-connected neighbors. The underlying color of the polygon is based on the which agent group is in the majority (i.e. a red polygon has more red agents than blue agents).

In addition to showing how to work with shapefiles within NetLogo we have also added some statics which you might find useful. The ability to calculate  Moran's I and a segregation index. Further  information  about the model can be found here and the code and data can be downloaded from here.

If you are interested in learning more about GIS and agent-based modeling in NetLogo it is worth checking out Yang Zhou's website Geospatial Computational Social Science.