[R-sig-Geo] How to convert results generated by "filled.contour" to shapefiles?

hadley wickham h.wickham at gmail.com
Fri Sep 12 14:50:40 CEST 2008


> The filled.contour() is a different kind of function, essentially doing
> almost everything in C, and passing nothing back. So I think the only
> alternative is to build polygons from the contourLines() output by
> intersecting with a bounding box, and then finding out which polygon
> boundaries are the ones needed and which attribute interval should be
> associated with them.
>
> My feeling would be that this kind of computational geometry might best be
> done outside R, though a lot can now be done with functions in spatstat and
> gpclib/PBSmapping. Alternatively, look at src/main/plot3d.c and check how
> the internals build their polygons. Returning them is hard - for
> contourLines I worked with Paul Murrell to expose the geometry in the way
> that it is now done - perhaps the same could be applied to
> filled.contours()?

A while back I talked to Ross Ihaka about doing the same thing for
filled.contours - and the result of our discussion was that you can
actually work them out from the output of contourLines.  Unfortunately
I seem to have lost my notes about exactly what you need to do, but I
think basically you need to find the incomplete polygons (i.e.
contours that meet edges) and complete them by intersecting them with
the rectangular bounding box of the plot.

Hadley


-- 
http://had.co.nz/




More information about the R-sig-Geo mailing list