[R-sig-Geo] polygon adjacency testing

Nikhil Kaza nikhil.list at gmail.com
Fri Aug 13 17:59:31 CEST 2010


I havent looked at poly2nb code, but would eliminating polygons from  
the polygon list based on area, perimeter  or ratio of these two,  
before constructing the neighbour list work? This would be similar,  
not identical, to eliminate in ArcInfo.
http://webhelp.esri.com/arcgisdesktop/9.2/index.cfm?TopicName=Eliminate%20%28Data%20Management%29

Nikhil Kaza
Asst. Professor,
City and Regional Planning
University of North Carolina

nikhil.list at gmail.com

On Aug 13, 2010, at 10:37 AM, Barry Rowlingson wrote:

> I've used poly2nb from spdep quite a bit, and occasionally it's shown
> up some errors in polygon data sets. For example, in the scottish data
> distributed with rgdal you'll see some rather wacky adjacencies:
>
> library(rgdal)
> scot=readOGR(system.file("vectors",package="rgdal"),"scot_BNG")
>
> library(spdep)
> nb = poly2nb(scot)
>
> plot(scot)
> plot(nb,coordinates(scot),add=TRUE,col="blue")
>
> There are some adjacency lines that go right across scotland (these
> would be clearer if you could choose different colours for each
> adjacency line, but it seems the plot method only uses the first
> colour of the col vector). Further investigation shows them to be due
> to slivers adjacent to areas remote from the main area, but in the
> same feature.
>
> Anyway, inspection of this kind of adjacency line map shows that in
> general, the adjacency lines drawn between centroids tend not to cross
> over one another if the data is well-behaved. So I started thinking
> about how to test if a set of line segments overlap.
>
> The rgeos LinesIntersection function almost works, except it counts
> two lines as intersecting if they start or end at the same point.
> Since so many adjacency lines do this, it might be hard to filter out
> false positives, although maybe it could be done since you know the
> polygon feature id and there's no point testing the intersection of
> lines with the same polygon feature id... hmmm thinking out loud here
> but maybe it will work...
>
> So anyway, anyone got an easy way of going from nb and
> coordinates(scot) to something that can be fed to
> rgeos:LinesIntersection to see which adjacency lines cross?
>
> Barry
>
> -- 
> blog: http://geospaced.blogspot.com/
> web: http://www.maths.lancs.ac.uk/~rowlings
> web: http://www.rowlingson.com/
> twitter: http://twitter.com/geospacedman
> pics: http://www.flickr.com/photos/spacedman
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list