On 10/06/2009 1:53 PM, Derek Lacoursiere wrote:> I have a list of polygons generated by the contourLines() command (each
> object of the list is a list in itself with two objects: a vector of x
> values, and a vector of y values for each vertex). I wish to convert that
> list into a gpc.poly object of multiple contours. How do I do this?
gpclib
> apparently has no method of coercing lists into the gpc.poly object type.
> As well, when I have a gpc.poly object, I can view the points using the
> get.pts() command, but cannot find a way of only extracting the x values of
> a polygon (or the y values, for that matter). How do I do this?
> Any help would be greatly appreciated
After running example(contourLines), this comes close:
lines <- contourLines(x,y,volcano)
pts <- lapply(lines, function(line) list(x=line$x, y=line$y, hole=F))
gp <- new("gpc.poly", pts=pts)
It is not quite right because some of the contours are incomplete, and
this joins them up, but it should give you the idea. I don't know how
gpc.poly handles partial polygons.
Duncan Murdoch