On 24/08/2014 08:51, Jan Tosovsky wrote:
Dear All,

I am trying to create vector output (SVG) of filled contours.

I've found two approaches so far:

(1)
library('lattice')
svg("D:/test.svg")
filled.contour(volcano)
#levelplot(volcano, panel=panel.levelplot.raster) # panel.levelplot.raster
will make it raster
dev.off()

(2)
library("raster")
svg("D:/test.svg")
rr <- raster(t(volcano))
rc <- cut(rr, breaks= 10)
pols <- rasterToPolygons(rc, dissolve=T)
spplot(pols)
dev.off()

But I'd like to get smooth closed polygons not broken into small cells.

But the region between two contours is not in general a closed polygon.

Are there better methods in R ?

Neither of those are 'in R'!

So you need to define your terms, precisely. How can a polygon (with piecewise linear boundaries) be 'smooth'?

But you could get a long way by looking at the following

?contourLines
?polygon
?grid::grid.polygon

all of which are part of R. R is a fully-fledged programming language and you could write SVG directly from R: using the svg device is limited by the steps to the R graphics primitives (see the 'R Internals' manual) and cairographics.

Thanks, Jan



--
Brian D. Ripley,                  [email protected]
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to