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