Skip to content
Prev 343403 / 398506 Next

Filled vector contours

On 2014-08-25 David Winsemius wrote:
Thanks, it looks similar, but in reality countours are just polylines not
connected into polygons and the fill is made from individual cells. But good
to know there is another way. I've realized it is a variant of commented
line in (1). So here is a simplified version:

(3)
library('lattice')
svg("D:/test.svg")
levelplot(volcano, contour=TRUE)
dev.off()

In the meantime I've found fourth one (based on Grid2Polygons library
example):

library(sp)
library(Grid2Polygons)
data(meuse.grid)
coordinates(meuse.grid) <- ~ x + y
gridded(meuse.grid) <- TRUE
meuse.grid <- as(meuse.grid, "SpatialGridDataFrame")
meuse.plys.lev <- Grid2Polygons(meuse.grid, "dist", level = TRUE)

svg("D:/meuse.svg")
plot(meuse.plys.lev, col = heat.colors(length(meuse.plys.lev)))
dev.off()

It is similar to (2). It actually doesn't produce smooth countours, just
joins cells into areas of the same fill/level. And these areas are
'isobands', not 'level plots' (or rather isolevels?).

I am leaving this open. For the future reference it would be nice to modify
code (4) for volcano data. I am lost here ;-)

Thanks, Jan