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

Roger Bivand Roger.Bivand at nhh.no
Fri Sep 12 18:10:40 CEST 2008


On Fri, 12 Sep 2008, hadley wickham wrote:

>> 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.

Thanks, the internals of plot3d.c are a bit forbidding, and there is an 
ominous FIXME suggesting that the contouring code ought to be factored out 
and hasn't yet been. So doing the computational geometry on the contour 
lines and a bounding box is the best offer for now.

Roger

>
> Hadley
>
>
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list