[R-sig-Geo] Shared polygon border
Roger Bivand
Roger.Bivand at nhh.no
Mon Oct 13 21:33:07 CEST 2008
On Mon, 13 Oct 2008, Jonathan Boyd Thayn wrote:
> I want to know the length of the shared border of neighboring polygons
> in a shapefile. I can use the slots () function to access the the
> "polyons" slot of the file, but I can't seem to create a list of the
> node coordinates of the polyon. Is there a way to do this easily?
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
> Thanks.
>
>
> Jonathan B. Thayn
> Ph.D. Candidate Geography and Remote Sensing
> University of Kansas
> 2101 Constant Avenue, Higuchi Hall, Rm 121
> Lawrence, Kansas 66047-3759
> jonthayn at ku.edu
> http://people.ku.edu/~jonthayn
>
>
> [[alternative HTML version deleted]]
>
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list