On Wed, Jun 9, 2010 at 3:24 PM, Edzer Pebesma <edzer.pebe...@uni-muenster.de> wrote: > The example provided by Matt assumes that each polygon consists of a > single ring, and doesn't have islands, lakes etc. The function below > pasts all coordinates to a single 2-column matrix. For clarity's sake, I > avoided nested sapply's. > > library(maptools) > xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], > IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66")) > allcoordinates = function(x) { > ret = NULL > polys = x...@polygons > for(i in 1:length(polys)) { > pp = polys[[...@polygons > for (j in 1:length(pp)) > ret = rbind(ret, coordinates(pp[[j]])) > } > ret > } > q = allcoordinates(xx) > > # check: > plot(xx) > lines(q, col='blue')
And that's basically what fortify does, except it covers a few more cases. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo