I have a 2D array of values and I'm trying to analyze spatial correlations. To calculate a 2D autocorrelation like Moran's I in python, pysal provides an implementation. 1) How do I transform my 2D data into a 1D array expected by pysal? 2) How do I construct a weight array w that is based on distance (what does the input array of points mean in the Kernel distance function?)?
Asked
Active
Viewed 619 times
4
-
That's probably too many questions, but if you get an answer to "how do I construct a weight array," please post it. – J Kelly Sep 19 '16 at 14:41
1 Answers
2
1) The weights array should be flattened in the same way as you flatten the data array. The order doesn't matter, as long as the indices agree.
2) The input array can be spatial coordinates (e.g. x and y, or lat and long). By far the easiest are the indices of your original matrix (e.g. 1 to n times 1 to m).
In the end, your data will be a list with 3 elements: x, y and value. Your weights will be a list with 5 elements: x_from, y_from, x_to, y_to and weight.

LBogaardt
- 402
- 1
- 4
- 25