[R-sig-Geo] how to code for neighbour list editing

James Rooney ROONEYJ4 at tcd.ie
Mon Jul 15 18:25:45 CEST 2013


Hi all,

Ok so I have a spatial data set with over 3000 polygons. I used poly2nb() to identify neighbour relationships and make an nb object. Of the polygons, about 30 or 40 are islands and have no neighbours according to polynb. Prior to doing Bayesian smoothing, I wish to assign neighbours to those islands (and probably weight them with a weaker weighting than true neighbours). Anyhow I've tried the edit tool for manually editing neighbours. Its basically not useful however since there are so many polygons its too hard to see the islands.

So I'd like to write some code to do something like this by manipulating the nblist:

1) Identify islands
2) For each island find nearest neighbour
3) Assign a neighbour relationship between the island and its nearest neighbour
4) Weight it appropriately (half normal weighting for example)

My problem is I don't really have any understanding of the nb object or how it stores relationships. I've tried summary() attributes() print() etc etc and can't really glean an insight into how to access or edit the inner structure of the nblist.

I was hoping someone might have dealt with this before. Or maybe there are functions for this I have yet to discover ?

Many thanks,
James


More information about the R-sig-Geo mailing list