Skip to content

pzatelli/HotSpotAnalysis_Plugin

 
 

Repository files navigation

Hotspot Analysis Plugin for QGIS

A QGIS Plugin to perform hotspot and cluster analysis based on the Python Spatial Analysis Library - PySAL.

The Hotspot analysis plugin computes Z-scores and p-values (under Complete Spatial Randomness hypothesis) of the Gi* local statistic (Getis and Ord, 1992; Getis and Ord, 1996), Anselin Local Moran's I (Anselin, 1995) and Local Moran Bivariate (Wartenberg, 1985; Anselin et al., 2002) for each geometry of a shapefile, with an assigned projected coordinate system and (at least) an associated numerical attribute. Output layer allows to identify spatial hot spots/cold spots) as well as clusters/outliers in the input vector dataset.

Concerning the Gi* local statistic, positive and statistically significant Z-scores indicate an intense cluster of high values (hotspot). Negative and statistically significant Z-scores indicate intense cluster of low values (coldspot). With respect to the Local Moran's I (and its bivariate counterpart, the Local Moran Bivariate), Z-scores are translated into quadrant values (q) of the Moran Scatterplot by informing on the presence of clusters or outliers within the dataset. Significance is computed, based on user's choice, against normality assumption or using permutations approach. By default, the significance level is set to 0.05. Please consider the litterature references included above for detailed information.

The spatial relationship between point features is modelled using a Fixed Distance Band (expressed with the same unit of measure of the projected coordinate system of the input point shapefile) or optionally using the K-nearest neighbour approach. For polygon shapefile analysis, the spatial relation is modelled using a queen's case contiguity matrix. For more information, please refer to e.g.: Geospatial Analysis - 5th Edition, 2015 - de Smith, Goodchild, Longley


Installation - Windows

1) Install dependencies:

Open OSGeo4W Shell installed with QGIS3 as Administrator and type:

 $ py3_env.bat
 $ python3 -m pip install --upgrade pip
 $ python3 -m pip install pysal==1.14.3 --user 

This will install in your QGIS3 Python 3 environment all the required dependencies. Be sure that the installed PySAL version is <= 1.14.3 Run python -m pip show pysal for checking it. If the installed version is higher, type python -m pip install -I pysal==1.14.3

2) Open QGIS:

Go to Plugins -> Manage and Install plugins -> Settings -> Show also experimental plugins

In All plugins tab, look for Hotspot Analysis and tick the checkbox.
A new icon for Hotspot Analysis will appear on the QGIS main panel and in the Vector Menu.

3) If you are interested in the latest unreleased version:

Download the zip folder of the repository at: https://github.com/danioxoli/HotSpotAnalysis_Plugin/archive/qgis3.zip

Open QGIS 3 and go to Plugins -> Install from ZIP

Select the downloaded zip folder and press Install plugin. The icon for the Hotspot Analysis plugin will appear in the list of the installed plugins. Tick the Checkbox to activate it. The plugin will appear in the Vector menu.

4) PySAL common error on Windows

  • Please, look at danioxoli#15

  • If the spreg functionalities of PySAL 1.14.3 generate import errors, go to the QGIS libraries folder at C:\Users\user\AppData\Roaming\Python\Python37\site-packages\pysal, open the script __init__.py and comment line n. 95


Installation - Ubuntu

1) Install dependencies:

Open a Terminal and type the commands:

 $ sudo apt-get install python3-pysal=1.14.3 

This will install in your QGIS3 Python 3 environment all the required dependencies. Be sure that the installed PySAL version is <= 1.14.3, Run aptitude versions pysal for checking it. If the installed version is higher, type apt-get install python3-pysal=1.14.3

2) Open QGIS 3:

Go to Plugins -> Manage and Install plugins -> Settings -> Show also experimental plugins

In All plugins tab, look for Hotspot Analysis and tick the Checkbox.
A new icon for Hotspot Analysis will appear on the QGIS main panel and in the Vector Menu.

3) If you are interested in the latest unreleased version:

Open a Terminal and change directory to QGIS Plugins directory, default is:

 $ cd /usr/share/qgis/python/plugins 

Clone the GitHub repository into the earlier mentioned path:

 $  sudo git clone -b qgis3 https://github.com/danioxoli/HotSpotAnalysis_Plugin

Alternatively

Download the zip folder of the repository at: https://github.com/danioxoli/HotSpotAnalysis_Plugin/archive/qgis3.zip

Open QGIS 3 and go to Plugins -> Install from ZIP

Select the downloaded zip folder and press Install plugin. The icon for the Hotspot Analysis plugin will appear in the list of the installed plugins. Tick the Checkbox to activate it. The plugin will appear in the Vector menu.


Installation - macOS

1) Install dependencies:

Open a Terminal and type the commands:

 $ sudo pip3 install pysal==1.14.3

Be sure that the installed PySAL version is <= 1.14.3 Run pip3 show pysal for checking it. If the installed version is higher, type pip3 install -I pysal==1.14.3

Alternative

Open a Terminal, update pip3, and install+update the dependencies numpy, scipy, and pysal (suggested by https://github.com/abuabara)

$ pip3 install --upgrade pip
$ sudo -H pip3 install -U numpy
$ sudo -H pip3 install -U scipy
$ sudo -H pip3 install -U pysal==1.14.3

2) Open QGIS:

Go to Plugins -> Manage and Install plugins -> Settings -> Show also experimental plugins

In All plugins tab, look for Hotspot Analysis and tick the Checkbox.
A new icon for Hotspot Analysis will appear on the QGIS main panel and in the Vector Menu.

3) If you are interested in the latest unreleased version:

Download the zip of the repository folder: https://github.com/danioxoli/HotSpotAnalysis_Plugin/archive/qgis3.zip

Go to Plugins -> Install from ZIP

Select the downloaded zip folder and press Install plugin. The icon for the Hotspot Analysis plugin will appear in the list of the installed plugins. Tick the Checkbox to activate it. The plugin will apear in the Vector menu.


Additional Material

A user guide with demo exercises is included here: https://github.com/danioxoli/HotSpotAnalysis_Plugin/blob/master/test_data/Hotspot_Analysis_UserGuide.pdf

Plese cite this as:

Oxoli, D., Prestifilippo, G., Bertocchi, D., Zurbaràn, M. (2017). Enabling spatial autocorrelation mapping in QGIS: The Hotspot Analysis Plugin. GEAM. GEOINGEGNERIA AMBIENTALE E MINERARIA, 151(2), 45-50.

Latest presentation available here: http://www.slideshare.net/danieleoxoli/hotspot-analysis-with-qgis-foss4git-2017

Note: most of this material is be based on old versions of the plugin!


Changeset

Changeset 10/2018
  • Enhancement to Gi* computation with negative values
  • Icon fixed
Changeset 03/2018
  • Plugin translation to QGIS 3
Changeset 06/2017
  • Enabled the use of k-nearest neighbor spatial weights matrix for point shapefiles
  • Minor bugs fixed
Changeset 03/2017
  • Enabled Anselin Local Moran's I and Bivariate Local Moran computation
  • Minor bugs fixed
Changeset 02/2017
  • The plugin has been officially published on the QGIS plugin repository
  • Minor bugs fixed
Changeset 01/2017
  • Enabled the use of negative numerical attributes Getis and Ord, 1996
  • Enabled polygon shapefiles as input using queen's case contiguity spatial weight matrix.
  • Enabled the possibility of selecting between normality assumption (default) and standard normal approximation from permutations to compute Gi* Z-scores and associated p-values.
Changeset 12/2016

New check botton to eneable the usage of row standardized spatial weights

Changeset 11/2016

With this new version, the output layer is displayed with an automatic style which enables hotspot and coldspot visualization. Moreover, a default Fixed Distance Band is dispalyed. This latter represents the minimum distance to ensure at least 1 neighbor to any element of the dataset in order to compute spatial weights for Gi*

Changeset 10/2016

The current version does not require Pyshp as well as to specify the feature coordinates as two separate fields in the attribute table of the input shapefile. Only the numerical attribute must be included and selected using the graphical interface on QGIS. Nevertheless, be sure that your input shapefile is projected. The unit of measure in which you express the analysis distance must agree with the one of the projected coordinate system of your input layer.


Future work

  • Test on the new functionalities addedd
  • improve GUI appereance
  • Update User guide and documentation for Anselin Local Moran's I and Bivariate Local Moran computation
  • Create a new branch of the sotware without external Python dependnecies

Bug tracker and Wiki

License

The Hotspot Analysis plugin is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation

Copyright © 2018 Daniele Oxoli/ Mayra Zurbaràn/ Gabriele Prestifilippo/ Stanly Shaji - Politecnico Di Milano.

E-mail: daniele.oxoli@polimi.it

About

A QGIS plugin for hotspot analysis

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • QML 50.1%
  • Python 37.6%
  • Makefile 8.0%
  • Batchfile 2.7%
  • Shell 1.6%