[R-sig-Geo] Plot local moran index "spdep"

Roger Bivand Roger.Bivand at nhh.no
Fri Oct 12 15:43:00 CEST 2012


On Fri, 12 Oct 2012, Jaime Burbano Girón wrote:

> Dear members of list,
>
> I calculated a local moran index ("localmoran()") for my data (which come
> from a raster grid) with a queen spatial neighbor structure for construct
> the weights matrix.
>
> I would like to plot in a map the value of local moran index for each zone,
> however, I am not sure how to extract spatial information for each one of
> the values obtained of local moran index.
>
> My question is: if I am well in assume that the result of localmoran()
> function is in the same order that neighbor list, thus, I can assign
> coordinates of neighbors to each row of result matrix? something like:
>
> #Calculating neighbors
> kneig=knearneigh(cbind(data$x,data$y),k=8)
> neig=knn2nb(neig)
>
> #Calculating weights for neighbors
> neiglist=nb2listw(neig,style="W")
>
> #Spatial autocorrelation
> lmt=localmoran(data$z,neiglist)
>
> #Data for plot local moran index
> data_map=cbind(lmt,data$x,data$y)

Yes, in principle. It is possible to specify the region.id component in 
the nb object, and check this against the IDs of data (or data$z) for 
safety's sake, but here you should be OK. Note the structure of lmt.

Roger

>
> Thanks in advance and best regards to all.
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no


More information about the R-sig-Geo mailing list