Skip to content

problem with 'islands' in neighbourhood matrix

2 messages · Meredith Franklin, Roger Bivand

#
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?
Thanks,
Meredith Franklin
#
On Tue, 7 Feb 2006, Meredith Franklin wrote:

            
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).