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.

2. Right click on “ ArcToolbox”, click “add Toolbox”
3.  Add the “AHP” toolbox (Fig.1)

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)

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

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)

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)

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

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

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.