[R] Coloring Dirichlet Tiles

Rolf Turner rolf.turner at xtra.co.nz
Mon Sep 5 02:51:14 CEST 2011


On 05/09/11 06:26, awesolow wrote:
> Hi,
>
> I have a set of x, y points (longitude/latitude) along with a z value
> representing an attribute at each point.  I want to create a
> Voronoi/Dirichlet tesselation of these points coloring each tile by the z
> value.  I tried searching for a way to solve this and it was suggested to
> use the dirichlet() command to get the correct coloring.  However, my
> coloring is not correct.
>
> Any thoughts?

Does something like this do what you want?

require(deldir)
set.seed(42)
x <- runif(20)
y <- runif(20)
z <- sample(1:6,20,TRUE)
d <- deldir(x,y)
td <- tile.list(d)
plot(td,polycol=z,close=TRUE)

Note that the tiling assumes planar Euclidean distance, which might
create distortion in dealing with points on a sphere if the region in
which you observe the points is large.

     cheers,

         Rolf Turner



More information about the R-help mailing list