[R] map on irregular grids

Ben Bolker bbolker at gmail.com
Fri Nov 5 03:22:51 CET 2010


Wolfgang Polasek <wolfgang.polasek <at> gmail.com> writes:

>    how to find a function for plotting polygon surface, like
> polgon3d(xc,yc,obs)
> 
> xc, yc ... coordinates
> obs.... observations
> result: persp plot with grid net over the coordinates

  Don't know of an off-the-shelf solution.  Generate a Delaunay triangulation
of your (x,y) points and then plot the triangles with triangles3d?

  Something like

set.seed(1001)
x <- runif(20)
y <- runif(20)
z <- rnorm(20,(x-0.5)^2+(y-0.5^2))
z <- (z-min(z))/(diff(range(z)))
library(tripack)
tt <- tri.mesh(x,y)
tt2 <- triangles(tt)
library(rgl)
tnodes <- c(t(tt2[,1:3]))
triangles3d(x[tnodes],y[tnodes],z[tnodes],col="blue")
bbox3d()



More information about the R-help mailing list