e.g. # x is a gpc.poly object as.Polygons.gpc.poly <- function(x, ID) { thisPolys <- lapply(get.pts(x), function(p) { Polygon(rbind(as.matrix(cbind(p$x,p$y)),c(p$x[1],p$y[1])), hole=p$hole) }) Polygons(thisPolys, ID) }
This works except if the gpc.poly is empty. `Polygons` fails if passed an empty list(). Felix On 8/9/07, Felix Andrews <[EMAIL PROTECTED]> wrote: > Hmm > > I'm trying to work with gpclib, converting to and from the sp classes. > I don't know what is/was in the package spgpc, but it is no longer > available: > > install.packages("spgpc", repos=rSpatial) > Warning: unable to access index for repository > http://r-spatial.sourceforge.net/R/bin/windows/contrib/2.5 > > The page http://r-spatial.sourceforge.net/xtra/xtra.RHnw.html says: > "the functionality described here has been included in packages rgdal, > naptools, and spgrass6, now all on CRAN. This page is maintained for > documentary purposes only, and most of the examples shown here are the > examples used in the released packages." > > where i'm guessing "naptools" should be "maptools". > But I can not find a method to coerce between "gpc.poly" and > "Polygons" classes. Not that it is difficult to manually... just > wondering. > > Felix > > -- > Felix Andrews / 安福立 > PhD candidate > Integrated Catchment Assessment and Management Centre > The Fenner School of Environment and Society > The Australian National University (Building 48A), ACT 0200 > Beijing Bag, Locked Bag 40, Kingston ACT 2604 > http://www.neurofractal.org/felix/ > voice:+86_1051404394 (in China) > mobile:+86_13522529265 (in China) > mobile:+61_410400963 (in Australia) > xmpp:[EMAIL PROTECTED] > 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8 > _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo