Skip to content
Prev 3335 / 29559 Next

How to check a large neighbourhood matrix?

Roger and Danlin:

Thanks for your help on this. This is the code I used to create and plot
the nb:

pc4.02=readShapePoly("..../pc4_2002/pc4_gebieden_2002",IDvar="PC4NR")
nb.pc4.02=poly2nb(pc4.02,snap=0.01)
coords=coordinates(pc4.02)
plot(pc4.02)
plot.nb(nb.pc4.02,coords,add=T)
summary(nb.pc4.02)
this plot. I wanted to specifically zoom in on the plot.nb() because it
shows the connections between the neighbours. I was able to check all the
areas with only 1 neighbour, but was afraid that there would be areas that
had only some of its neighbours assigned correctly. I will try to use xlim=
en ylim= to zoom in on the plot. I think writeOGR() is not really an option
because it will not show the lines connecting the neighbours that plot.nb()
so nicely does.

Oscar
On Thu, 27 Mar 2008, Danlin Yu wrote:

            
I think that Oscar had got this far using the prefered sp object:

SPDF <- readShapePoly()

nb <- poly2nb(SPDF)

but had needed to use the snap= argument to poly2nb() to overcome slivers
in his polygons.
This helps, because it says which have no neighbours. It will indicate how
to "zoom" in on the plot for the locations of the polygons. To actually
"zoom", use xlim= and ylim= in the plot method for nb objects.

If you want real control, consider writeOGR(SPDF, ..., driver="KML") in
the rgdal package, and equivalently writeOGR() of the
SpatialLinesDataFrame output by nb2lines(), and zoom to your satisfaction
in GE using KML files.

Roger