[R] GeoDa spdep

Roger Bivand Roger.Bivand at nhh.no
Tue Apr 1 12:27:13 CEST 2008


Steve Schachterle <steve.schachterle <at> gmail.com> writes:

> 
> My question is in regard to the spdep and GeoDa packages.  Do you know how
> to extract a neighborhood/adjacency matrix from R?  I need a matrix that has
> all the neighborhoods on the X and Y axis, and then a r=1 when the
> neighborhoods touch, and a r=0 when neighborhoods don't touch.  I
> think the Moran's I functions use a matrix like this when they estimate
> Moran's I.  I  can estimate Moran's I,  but I can't figure out how to
> extract the matrix.  I've been trying to do this for months and I
> just can't get it.

Look at the help for listw2mat or equivalently nb2mat in spdep - they make 
square matrices from spatial weight and spatial neighbour list objects 
respectively. The output matrix will be very sparse. 

As far as I know, you can make such matrices by reading GeoDa GAL or GWT 
files into R, and then convert them to matrices as just described.

Denizens of the GeoDa openspace list, or R's very own R-sig-geo could have 
helped quickly if you'd asked.

Roger

> 
> Thank you so much.  The R project is an invaluable gift to the scientific
> and statistical community.
> 
> Steve
>



More information about the R-help mailing list