Skip to content
Prev 77367 / 398502 Next

Question:manipulating spatial data using combination of Maptools and Splancs

On Fri, 16 Sep 2005, kostas karis wrote:

            
Say you have a shapefile of points, and a shapefile with one single ring 
polygon, no holes or other geometry objects, then using maptools 0.5-2:
Loading required package: foreign
Loading required package: sp
Shapefile type: Polygon, (5), # of Shapes: 1
Conversion is by
+    getSpPpolygonsSlot(cardiff_poly)[[1]])[[1]])

to unpack the coordinates of the points and the single ring boundary. If 
you have more than one shape, and/or more than one ring in that shape, 
adjust the [[Shape]])[[ring]] indices to suit. Then:
+    add=TRUE)
works as expected. Extracting the polygon looks complicated because 
shapefiles have a "richer" geometry than splancs. Wrapper functions for 
splancs to use the sp classes now used by maptools will be available 
before long.