You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects Visual Basic for Application (VBA) forum

Grid Correlation   Ina Zander Jan 26, 2006
Re: Grid Correlation   William Huber Jan 31, 2006
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Grid Correlation 
Author Ina Zander 
Date Jan 26, 2006 
Message Dear all,

working with ArcGIS9 I am not very familiar with VBA-Scripts. But I am looking for scripts or extensions that can do correlation (maybe Pearson- or product-momentum-correlation) by moving window (with changeable size) for two grids. Until now I haven't found a way to do these things with Spatial Analyst or ArcToolbox. Any help would be appreciated. Thank You!

Ina Zander 
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Grid Correlation 
Author William Huber 
Date Jan 31, 2006 
Message Ina,

Spatial Analyst can be persuaded to compute a moving window correlation grid.

To obtain consistent results around the edges, you will need an indicator grid to identify (and later count) the cells where neither of your grids [X] and [Y] is empty. Start by computing the product grid [XY] as [X]*[Y]. One way to produce this indicator (let's call it [I]) is to compute

[XY] - [XY] + 1

This will have 1's in all cells where [XY] is not null and will otherwise be null.

At this point, replace the original grid [X] with [X]*[I] and replace [Y] with [Y]*[I].

Having done these preliminaries, compute the squares of the grids: the square [XX] equals [X]*[X], and the square [YY] equals [Y]*[Y].

The moving-window correlation grid is computed from focal means. Choose a window size and shape. Using this, compute the focal means of [X], [Y], [XX], [YY], and [XY]. Let's call the resulting grids [Xm], [Ym], [XXm], [YYm], and [XYm], respectively. The correlation grid, by definition, is

([XYm] - [Xm]*[Ym]) / Sqrt(([XXm] - [Xm]*[Xm])*([YYm] - [Ym]*[Ym]))

It will have non-null values at all cells having neighborhoods where two more more cells both have non-null values of [X] and [Y] and not all values of [X] and [Y] in those neighborhoods are constant. 
  --Bill Huber
Quantitative Decisions ( )
More GIS Q&A at