Skip to content
Prev 782 / 29559 Next

problem with 'islands' in neighbourhood matrix

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