Skip to content

matrix to gal object

2 messages · bernardo lagos alvarez, Roger Bivand

#
useR's

I need transform the matrix

wdat
     [,1] [,2] [,3] [,4] [,5] [,6]
[1,]    0    1    0    1    1    0
[2,]    1    0    0    1    1    0
[3,]    0    0    0    0    1    1
[4,]    1    1    0    0    1    0
[5,]    1    1    1    1    0    0
[6,]    0    0    1    0    0    0


to  gal object. How I do with spdep?


Thanks in advance for the help.

Bernardo.
University  of Concepci?.
#
bernardo lagos alvarez <blacertain <at> gmail.com> writes:
RSiteSearch("matrix listw")

gets you to several threads on the R-sig-geo list, suggesting in your case:

w <- mat2listw(wdat)
# convert matrix to spatial weights list
write.nb.gal(w$neighbours, "wdat.gal")
# write neighbours component of spatial weights list as GAL file

Roger Bivand