How does one turn contour lines into filled contours?

前端 未结 3 1343
情话喂你
情话喂你 2020-12-14 12:11

Does anyone know of a way to turn the output of contourLines polygons in order to plot as filled contours, as with filled.contours. Is there an ord

3条回答
  •  失恋的感觉
    2020-12-14 12:18

    A solution that uses the raster package (which calls rgeos and sp). The output is a SpatialPolygonsDataFrame that will cover every value in your grid:

    library('raster')
    rr <- raster(t(volcano))
    rc <- cut(rr, breaks= 10)
    pols <- rasterToPolygons(rc, dissolve=T)
    spplot(pols)
    

    Here's a discussion that will show you how to simplify ('prettify') the resulting polygons.

    enter image description here

提交回复
热议问题