Digital Geography

18. April 2015

AHP for ArcGIS 10.x using Python

When it comes to site selection problems or suitability models, the spatial Multi-Criteria Analysis (Weighted Overlay) is the most commonly used method. It’s easy, simple and popular. However, if it’s your first time to come across this method, it’s highly recommended to have a look at this link.

After defining the problem you want to solve, the next 4-steps are followed to perform this method.

  1. Determine significant layers.
  2. Reclassify the layers.
  3. Weight the input layers.
  4. Sum up the weighted layers

My concern was always about how I can assign a weight to each layer in a kind of scientific way. However, Analytic Hierarchy Process (AHP) sorted it out. Wiki defines it as “A structured technique for organizing and analyzing complex decisions, based on mathematics and psychology. It was developed by Thomas L. Saaty in the 1970s and has been extensively studied and refined since then”.

The main concept of AHP is to pair-wise compare all criteria. A value of 1 expresses “equal importance” and a value of 9 is given for those factors having an “extreme importance” over another factor in a comparison matrix.

To get a full description of this method, I do recommend these two videos which illustrate this method in a decent way.

Well, I found a tool that integrates the AHP method within ArcGIS Environment, but, unfortunately, it is compatible with ArcGIS 9.x only!. Therefore, I said why I don’t integrate these calculations within ArcGIS 10.x (tested on 10.2). Python scripting and ArcPy are used.

  1. Download the AHPforArcGIS10.x file and extract it.
  2. Right click on “ ArcToolbox”, click “add Toolbox”
  3.  Add the “AHP” toolbox (Fig.1)

    Fig1

  4. Double click on the (AHPstep1) script tool. This tool is developed to create an emptyAHP matrix that should be filled by the user. The tool is designed to identify all raster layers in the TOC. However, any vector layers will be ignored (Fig.2)

    Fig2

    In this example I have 5 layers in the TOC, the first two are vector layers and the rest are raster layers(fig.3).

    Fig3

  5. Choose the “File Geodatabase” that you want to save the matrix in.
  6. Choose a name for that comparison matrix.
  7. An empty matrix is generated in the “file Geodatabase” (as illustrated in the figure, the names of the layers are automatically assigned to the matrix).
  8. Add the table (matrix) to theArcMap and fill it (you can add /remove any desired field/row) (Fig.4)

    Fig4

  9. Double click on the (AHP step2) script tool. This tool is designed to analyse the comparison matrix and to generate the consistency index (CI) as well as consistency ratio (CR).
  10. Add the filled matrix (Fig.5)

    Fig5

  11. Another table will be added in the same filegeodatabase with a suffix (CI), refereeing to Consistency Index (Fig.6)

    Fig6

  12. The generated table lists the weights of each layer, consistency index (CI), consistency ratio (CR) and average consistency index (RI) (Fig.7)

    Fig7

If (CR) exceeds a value of 1, a message states “The comparison matrix should be improved.” appears in the “Notes” field, while a message states “The matrix is considered to be consistent enough “appears if the CR is less than the value of 1.

Note: the Maximum number of raster layers is 15 while the minimum number is 2. Otherwise, an error message appears.

Feel free to download the AHPforArcGIS10.x tool (with Python scripts).

Your comments are more than welcome.

  • MGM

    Great to see this post. Can anyone tell, what is the next step? I mean, how to use this matrix with weighted values in ArcGIS to obtain final suitability map?

  • Samuel Fernández

    Thanks a lot! This tool is too much useful. Thanks for sharing!

    • Habboub

      Welcome, Samuel.
      Happy to hear that 🙂

  • Shashi Bhattarai

    Thanks for sharing this useful information. I have further shared this at https://www.facebook.com/AHPforDecisionMaking

  • Muhammad Saad

    Aoa Sir.Hope u are fine. i am studying geo informatics engineering From Nust.sir I just need to know how can i implement AHP in python for site suitability of vegetation type.. sir kindly plz send me any link or tutorial video in which AHP implementation in python for site suitability is described ..As this is Part of my final year project..Plz consider this its a request

  • ‫يزيد الدرويش‬‎

    I need AHPforArcGIS9.x

  • Hasan Zorba

    Hi, I use arcgis 10.2.2. ,yet the fundemantel problem is that we havent run Ahp for Arcgis using python.This programme should be compatible my using arcgis .So do you have any document to run this process ? Should you sent me with pdf or word? Thank you

  • pankaj

    I am not getting step 1 and step 2 script with AHP tool. Can anyone help me with this?