Pages

Friday 30 August 2013

Neighborhood analysis in QGIS.


QGIS is an open source software which anyone can download for free. The community is growing each day and it is completely capable of doing common basic GIS tasks as well as more advance stuff. In this tutorial, I will show you how to do some neighbourhood analysis in QGIS with the help of sextante graphical modeler. If you guys are more ArcGIS person then you might be familiar with ArcGIS modeler. QGIS provides similar graphical interface as ArcGIS through which all the available algorithms in QGIS are accessible. On top of that you can combine algorithms from different other providers such as GDAL, Grass, OrfeoToolbox, R and SagaGIS. So it can be really powerful tool to automate your daily GIS task. Go check it out. Scour help file of QGIS, you will find plenty of readings.

Different programs that are available with QGIS

So the task is: There is a polygon shape file of my country Nepal which is shown in green. Each polygon represents a district. There is a point shp file which represent point of interest (assume it to be major infrastructures such as big hospitals or airports or universities etc). Each point of interest is represented by unique ID. Now the task is to assign each district to closest point of interest based on how far the district is from point of interest
Input shpfiles: 
The graphical model in QGIS.


The model is basically doing following main task.
  • ·         Convert shp file districts to its centroid
  • ·         Calculate nearest point of interest from each district centroid.

After creating the model one could just hit the run button and you are good to go. The model can be saved and used it for later purpose. As you can see in the modeller, the first algorithm is coming from SAGA GIS whereas second algorithms is coming from core QGIS. This is also a good illustration to show how algorithms can be combined from different source.

After running the model, you will get a point file. Let’s examine its attribute table. As you can see, each district is associated with @HubName which in our case is point of interest. It also has distance information. I forgot to converts projection EPSG: 4632 to a projected one so the distance is in terms of latitude and longitude. If you want distance in m or km then use a projected EPSG and you will be fine.



Now we will join this information to the original district shp file based on the column @Name. To do that do the following:

Right click the polygon shp file and click properties. Click join tab and following figure pops up. Click green + button to define a join as shown in next figure. The join column is @Name which is common is both polygon shp files as well point shp files that we calculated from our graphical modeler

Join attribute interface
.
Defining join layer and columns

After the join, the attribute of districts polygon has additional information. Now it’s the matter of applying colour symbology to differentiate which districts are closer to which one of the point of interest based on fourth column.

Attribute table after join

The final result is :

I have not shown each and every step in this tutorial. My main purpose is to show how you can use powerful QGIS and sextante modeler to perform complex GIS task such as neighborhood analysis without using ArcGIS which costs a lot and stimulate you to try QGIS. If any questions, just ask and I will reply. Of course, if I am not busy with my shits J