problem with 'islands' in neighbourhood matrix
On Tue, 7 Feb 2006, Meredith Franklin wrote:
I created a neighbourhood matrix in GeoDa and have read it into R using read.gal (spdep package). I have a few zero-neighbour polygons and as a result I cannot apply nb2listw to my nb object. Is there a way to get around this problem when reading in the .gal file or do these islands need to be removed before creating the matrix?
Functions in spdep use an argument called zero.policy=, set by default to FALSE, which stop you using neighbour or weights lists with zero-neighbour entities. You override this by saying zero.policy=TRUE. An alternative is to subset your data and the neighbour list: have_neighbours <- card(nb) > 0 sub_nb <- subset(nb, have_neighbours) sub_data <- subset(data, have_neighbours) So the problem can be handled internally. Finally, if you want to stitch them onto the graph of neighbours, have a look at ?edit.nb (you'll need the centroids of the polygons for this).
Thanks, Meredith Franklin
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, 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