File Exchange

image thumbnail

Moran's I

version 1.0.0.0 (2.53 KB) by Felix Hebeler
Calculates local Moran's I index of spatial correlation for raster.

18 Downloads

Updated 31 Mar 2016

View License

PURPOSE: calculate local Moran's I for a local grid using a weight matrix.
-------------------------------------------------------------------
USAGE: m = moransI(grid, W, s);
where: [grid] is the matrix to analyze
[W] is the normalized weight matrix of the size the local Moran's I will be calculated for
[s] is an optional flag to use zscores of input values for calculation. Set to 'true' if zscores of local grid should be calculated. Leave blank if not desired or input values are already standardized. -------------------------------------------------------------------------
OUTPUTS:
[m] Moran's I of input raster weighted using [W]
-------------------------------------------------------------------
NOTES: Weight matrix needs to be 'moving window' style, not contiguity matrix: Moran's I is calculated and weighted for neighbours to center cell. Matrix needs to be normalized (weights sum to 1) and center cell weight will be set to 0 if not already.
See Anselin (1995, 'LISA.', Geogr. Analysis 27(2),p.93f) for details on standardized variables in calculation of local Moran's I.

Cite As

Felix Hebeler (2019). Moran's I (https://www.mathworks.com/matlabcentral/fileexchange/13663-moran-s-i), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (12)

How can you obtain the colormap you show on the main image? How does it relate to the M you get as output?

Thuy-My Le

Hi. Thanks for creating this, but I'm new to spatial indexes. Can you explain what a moving window style matrix is? Thanks.

lei nie

ahmad azizi

soyoung an

This is using wrong method ! it's not about moran's I-_-

Nada Kadhim

Hi Felix,

Thank you for sharing your codes with us.
I have applied on my own image and I got great results. However, in the beginning the code did not work but when I changed the size of window to 3*3 and then it works.

Can Yang

when it run , the result i got is a full matrix with NAN,why ?? does it because the data is too big?? thanks

J G

Thanks for this - I am new to spatial statistics and I need a little help to use this function. I have ~200 latitude and longitude points, and data associated with each point. How do I use this function? Thanks! (Sorry)

Amit

on my MATLABR2010B, the Morans function is not available.
What I can do now?
Plz sort out it.

I would like to calculate the Geary's index for 2 dimension data. the equation is same as the Moran's index but it's not local.
Can you help me please.

Jim

Should this function work in one dimension? When I call,

M = morans_I(sourceDataRow,ones(1,3)./3,'true');

I get zeros. When I call,

M = moransI(sourceDataRow,ones(1,3)./3,'true');

I get seemingly correct results, but some values are greater than 1, which should not exist.

Jay Lennard

Ok, but use of confilt or nlfilter would speed up things (would require imageprocessing toolbox)

Updates

1.0.0.0

BSD update

1.0.0.0

.

-> updated version uses colfilt to increase speed about factor 10 - image processing toolbox required.
-> Original version renamed to morans_I() does not need IPT.

Updated version
- Includes loop for whole matrix
- use zscores()
- includes example

MATLAB Release Compatibility
Created with R2006a
Compatible with any release
Platform Compatibility
Windows macOS Linux