Implementing Spatial Autocorrelation using QGIS or PostgreSQL or any other free application?

Learning by doing is my preferred way. And when it comes to spatial statistics, R is getting seriously powerful tool. So if this is an option browse through some course materials, download the data and try it yourself.

Few starting points covering spatial autocorrelation (SA) (and generally speaking handling spatial stuff in R):

  1. Center for Studies in Demography and Ecology (CSDE) at University of Washington provides materials from Spatial R workshop.

  2. Institute for Quantitative Social Science at Harvard University has materials from the Applied Spatial Statistics in R workshop covering SA.

  3. Geography Department at the University of Colorado offers materials on SA as part of its Introduction to Quantitative Methods course.

Once you get some familiarity with R you can couple it with PostgreSQL using PL/R - R Procedural Language for PostgreSQL, but I cannot comment on it since I'm not knowledgeable on the topic.

Python might be another alternative. PySAL is an actively developed and well documented library that will let you implement all of GeoDa functionality, including SA (and most likely, even more). Python and Postgres are usually good friends so investing some time you could most likely marry those two as well.


I have no idea how to perform your QGIS/PostgreSQL idea but the following software can calculate measures for autocorrelation

  • GeoDa http://geodacenter.asu.edu/ogeoda
  • Passage 2 http://www.passagesoftware.net/
  • SAM (Spatial Analysis in Macroecology) http://www.ecoevol.ufg.br/sam/
  • PAST http://folk.uio.no/ohammer/past/
  • SAGA GIS http://www.saga-gis.org/en/index.html

GeoDa can only handle vector, Passage2 and SAGA only raster, PAST only XYZ.txt and SAM (I think) both.


Art Lembo has a simple example of a pseudo-Moran's I for PostGIS:

SELECT corr(a.pctwhite, b.pctwhite)
FROM cleveland AS a, cleveland AS b
WHERE st_touches(a.geometry, b.geometry)
AND a."OID" <> b."OID"

The key here is that - as he puts it . . .

[Moran's I] is really nothing more than Pearsons Correlation Coefficient tricked into a spatial context

. . . meaning that a basic contiguity test can produce a credible matrix and evaluation. I've tested this on my own data and found it to produce really-similar results to other Moran's I implementations.