Pages

Friday, September 25, 2015

Reimplementation of the Urban Growth Model in Netlogo

Recently, I have partially re-implemented the Urban Growth Model (UGM) that was developed by Clarke, Hoppen and Gaydos using Netlogo. The study area is the City of Santa Fe in New Mexico, USA.

Here is a picture showing the simulation results after 10 periods:


A video recording a simulation process of the model can be found here:



The code and data could be found here:
<https://github.com/YangZhouCSS/Urban_Growth_Model>


The image below shows the road types and landuse types in the area studied.


In this post, I will briefly talk about how I re-implemented the UGM using Netlogo. The purpose of this model and this post is to assist people who are interested in urban growth and urbanization as well as those interested in learning Netlogo.

The urban growth dynamic implemented in the Urban Growth Model (UGM) contains four types of growth, namely:
(i) Spontaneous Growth - defines the occurrence of random urbanization of land.
(ii) New Spreading Centers - determines whether any of the new, spontaneously urbanized cells will become new urban spreading centers.
(iii) Edge Growth - defines the part of the growth that stems from existing spreading centers.
(iv) Road-Influenced Growth - agents take a road trip along a transportation infrastructure and look for suitable space for urbanization.
Note: Self Modification is not included in this model.

More information regarding the growth process can be found on the project website:

The original paper of the theory of the UGM:

The codes to implement the four types of growth are relatively easy. I would like to talk about the codes that solve the following problems:

1.       How to load GIS data (usually a map) into Netlogo?

The GIS extension of Netlogo allows users to load .asc data into Netlogo. A map can be converted into .asc files in ArcGIS using the tool called “Raster to ASCII”. This process will convert a map into a grid file which contains the size and location information of the whole grid as well as information of each cell.

Here is an example about how to import .asc file into Netlogo:

set urban-dataset gis:load-dataset "data/urban_santafe.asc"

Here I created a global variable called urban-dataset and load the data file into the global variable using “gis:load-dataset”.

Then I have this line:
gis:set-world-envelope gis:envelope-of urban-dataset

“gis:set-world-envelope gis:envelope-of” is a shorthand for setting the transformation by mapping the envelope of the NetLogo world to the given envelope in GIS space, while keeping the scales along the x and y axis the same.

To copy values from the given raster dataset to the given patch variable in Netlogo, I use this line:
gis:apply-raster urban-dataset urban

Note that the grid size in Netlogo is exactly the same as the original data, meaning that they have same numbers of rows and columns.

2.       How to export the results as .asc files so that we can edit it in ArcGIS?

The following codes are used to export the .asc file.



The first few lines with “file-print” are asking Netlogo to write the beginning of the .asc file. This part should be identical to the original data, since we did not modify the size of the grid.

The while loop asks patches in row i to write their urban variable into result.asc file. As i decreases from 393 to 0, we are going through the rows from the first row on top to the one at the bottom.

I wish you are enjoying this post!

Reference:



15 comments:

  1. Hello Yang Zhou ,
    Congratulations on your netlogo implementation of SEUTH. I have previously tried it but with no success, and now with your implementation hope I can have results. Just wanted to ask what has been left out because you say that is a partial re-implementation. Thanks in advanced for your answer. Regards,

    Javier

    ReplyDelete
    Replies
    1. Hi Javier,

      I did not include Self modification in this model. Self modification will change the growth coefficients over time. Please see the following website for more information regarding Self modification.

      http://www.ncgia.ucsb.edu/projects/gig/About/gwSelfMod.htm

      Thank you for your interest!

      Best,
      Yang

      Delete
  2. Hi Yang, nice explanation on the implementation of SLEUTH using ABM. I have few questions regarding the code on Netlogo. On the file-print lines, you put "... \r\n", what does "\r\n" means? Secondly, when I create a raster map from ArcGIS and import it to NetLogo, NetLogo cannot handle the cells with noData value which is labelled as NaN on NetLogo. I found post how to handle NaN using something like ifelse [value > 0] or [value < 0] but I didnt work on my case. Do you know how to handle NaN on Netlogo? Cheers. Agung. (apologize if the questions are too trivial, i am still new on Netlogo and still learning)

    ReplyDelete
    Replies
    1. Apologize, I found the solution for the NaN on Netlogo. I should put the ">=" sign instead of just ">".

      Delete
    2. Hi Agung, \r\n means start a new line in the text file. Sorry for the last response. I am glad that you solved the NaN problem!

      Delete
  3. Dear Yang,

    Thank you for this implementation. I'm a GIS specialist learning right now NetLogo and I found your work extremely helpful in setting the environment for my work.

    Cheers, Piotr Dzieszko.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Hello Yang Zhou,

    Thank you for such a wonderful re-implementation of SLEUTH. I am extremely new to Netlogo and I have a couple of questions. Is this GIS extension from https://github.com/NetLogo/GIS-Extension ? If it is, do I have to install this extension to my Netlogo first? (but your code ran fine without the extension installed on my Netlogo. Or is the extension was included in Netlogo 5.3.1 already?

    Thank you very much!

    ReplyDelete
    Replies
    1. Also I have a problem running the model when I turn road_influence ON. The program just hangs. Anyone else face this problem?

      Delete
    2. Hi Bobo, the GIS extension is included in Netlogo 5.3.1, so you don't have to install it separately. I do realize that when road_influence is turned on, the model is extremely slow. The problem could be solved by either implementing a more efficient algorithm, or to write it in a faster language (java for example).

      Delete
  6. Hello Yang,

    Thank you for the contribution towards this partial but extremely helpful re-implementation. I'm using it to simulate the urban growth of an African city and I have one question. As you rightly mentioned, activating the road influence growth increases the computational time considerably. Indeed, using core i5 windows machine with 8G memory, I could not get even a tick for over 12 hours. I'm therefore contemplating on turning the road influence off BUT will the road gravity coefficient still work? Thus, will I still have road gravity effect in the model if I turn the road influence button off but adjust the road gravity coefficient slider?

    Best wishes
    Felix

    ReplyDelete
  7. Hello Yang,

    Thank you for the contribution towards this partial but extremely helpful re-implementation. I'm using it to simulate the urban growth of an African city and I have one question. As you rightly mentioned, activating the road influence growth increases the computational time considerably. Indeed, using core i5 windows machine with 8G memory, I could not get even a tick for over 12 hours. I'm therefore contemplating on turning the road influence off BUT will the road gravity coefficient still work? Thus, will I still have road gravity effect in the model if I turn the road influence button off but adjust the road gravity coefficient slider?

    Best wishes

    ReplyDelete
    Replies
    1. Hi Felix,

      Unfortunately, you will not have road gravity effect if you turn off road_influence. The problem could be solved by either implementing a more efficient algorithm, or to write it in a faster language (java for example). I may be able to do that in the future when time permits.

      Delete
  8. The foremost thing in writing an essay is to know how to write an essay outline. Until and unless you have the structure ready you can not fathom how far you need to go. The initial process starts with this format. It gives you an idea where you need to concentrate the most. In any form of essay writing the idea is considered the crux of the matter. The idea needs to be jotted down somewhere. This is where the outline of the essay comes handy. essay writing

    ReplyDelete