Skip to content
Prev 4335 / 29559 Next

Shared polygon border

On Mon, 13 Oct 2008, Jonathan Boyd Thayn wrote:

            
I imagine that you mean the end nodes of arcs with known left and right 
neighbours? The actual ring coordinates are simply the "coords" slots of 
each "Polygon" object in the list in the "Polygons" slot of each 
"Polygons" object in the list in the "polygons" slot of the 
SpatialPolygons object (for a very special definition of "simple"). But 
they wouldn't help much, because you need to build the topology first. If 
you have access to ArcGIS, you can push the polygons out for Arc as a 
shapefile, convert them into a coverage (if they build cleanly) and get 
the coverage back into R using readOGR as both polygons and arcs:

http://www.asdar-book.org/exercises.php?excode=3

and link therein. Getting the lengths from the arcs could use 
SpatialLinesLengths() in sp, and add the values to the 
SpatialLinesDataFrame; this function assumes planar coordinates at 
present. The coverage2nb() would need gentle editing to return a list of 
lengths in the same format as the nb object.

If GRASS is OK, look at vect2neigh() in the spgrass6 package by Markus 
Neteler - it does what you want if the topology builds cleanly, and 
possibly not on all platforms.

Hope this helps,

Roger