[R] Clip contour or image
Thomas Petzoldt
petzoldt at rcs.urz.tu-dresden.de
Tue Mar 20 09:50:17 CET 2001
Pierre Kleiber wrote:
>
> I was going to suggest masking the ouside of a selected contour
> line using the function antipolygon(), which I have written. However,
> I see that contour() in R does not have the ability to return contour
> lines as x, y vectors as it does in Splus. This is a feature I found
> useful before I switched to R. Question for the R gurus... Would it
> be difficult to add this feature to R's version of coutour()?
>
> By the way... this is my antipolygon function:
>
> antipolygon <- function(x,y,col=0){
> u <- par("usr")
> x <- c(x,x[1],u[1],u[1],u[2],u[2],u[1])
> y <- c(y,y[1],u[3],u[4],u[4],u[3],u[3])
> polygon(x,y,border=col,col=col)
> box()
> }
Hello Pierre,
as a first approach I have used a script similar to your antipiolygon.
However, the problem is that this will affect the graphics on
screen only (or in the graphics file) but not the image data.
If one needs the data to make additional computations (e.g. compute
areas
and volumes of geostatistical data) a manipulation of the (1) image
matrix
or the (2) contour lines is required.
My approach uses method (1) but method (2), getting and
manipulating contour lines as vector data, would have some advantages.
Unfortunately, method (2) would require a modification of the contour
source code plot3d.c which will exceed my knowledge about graphic
algorithms and R internals (see discussion "get vector data from
contour" in february).
Thomas Petzoldt
--
Thomas Petzoldt (Limnology & Ecological Modelling)
Dresden University of Technology
Institute for Hydrobiology
mailto:petzoldt at rcs.urz.tu-dresden.de
01062 Dresden http://www.tu-dresden.de/fghhihb/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list