Correlation multiple fields raster

2458
1
03-19-2012 10:44 AM
IgnacioPalomo
New Contributor
Hi,

I have a raster with many fields (result of combination of various raster). I want to analyse correlation among fields, but rows refer to different number of pixels. So if i export the table to excell, i couldnt analyze it without bias to most repeated pixels. I created a point layer and tried to extract values to points, but I get an error all the time. Is there other method to export a raster table in which every pixel becomes a different row?

Thanks a lot!!
0 Kudos
1 Reply
DrewFlater
Esri Regular Contributor
The Python numeric package NumPy has a good correlation function, and you can also easily convert raster to NumPy arrays in ArcGIS 10.0. Here is a short script that I've used before, to calculate the correlation coefficient between two rasters:

import numpy
array1 = arcpy.RasterToNumPyArray("per_under30.tif")
array2 = arcpy.RasterToNumPyArray("per_renter.tif")
print numpy.corrcoef(array1.ravel(), array2.ravel())


You will just need to split your single raster with multiple attributes into multiple rasters. This will return a correlation matrix like this:

[[ 1.          0.28250181]
[ 0.28250181  1.        ]]


...so between my two variables there is a 0.28xxx correlation coefficient (between the same variable of course the correlation coefficient is 1).

Here's some more information on the NumPy corrcoef function: http://docs.scipy.org/doc/numpy/reference/generated/numpy.corrcoef.html

Good luck!
Drew
0 Kudos