[R] Coloring Dirichlet Tiles
Felix Andrews
felix at nfrac.org
Tue Sep 6 13:18:16 CEST 2011
On 5 September 2011 06:59, baptiste auguie
<baptiste.auguie at googlemail.com> wrote:
> Hi,
>
> Try this,
>
> d <- data.frame(x=runif(1e3, 0, 30), y=runif(1e3, 0, 30))
> d$z = (d$x - 15)^2 + (d$y - 15)^2
>
> library(spatstat)
> library(maptools)
>
> W <- ripras(df, shape="rectangle")
> W <- owin(c(0, 30), c(0, 30))
> X <- as.ppp(d, W=W)
> Y <- dirichlet(X)
> Z <- as(Y, "SpatialPolygons")
> plot(Z, col=grey(d$z/max(d$z)))
>
> and also panel.voronoi in latticeExtra.
>
> Unfortunately I do not know of a solution that uses more efficient
> algorithms for computing the Dirichlet tessellation and extracting
> tiles than those relying on deldir. The Triangle package (r-forge)
> looks promising.
panel.voronoi() can use either deldir or tripack. tripack is non-free
but is much faster.
xyz <- data.frame(x = rnorm(1000), y = rnorm(1000), z = rnorm(1000))
library(latticeExtra)
system.time(print(tileplot(z ~ x * y, xyz))) ## deldir by default
# user system elapsed
# 3.636 0.004 3.651
system.time(print(tileplot(z ~ x * y, xyz, use.tripack = TRUE)))
# user system elapsed
# 1.176 0.000 1.359
>
> HTH,
>
> baptiste
>
>
> On 5 September 2011 06:26, awesolow <awesolow at andrew.cmu.edu> 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?
>>
>> Thanks in advance.
>>
>> --
>> View this message in context: http://r.789695.n4.nabble.com/Coloring-Dirichlet-Tiles-tp3789746p3789746.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org 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.
>>
>
> ______________________________________________
> R-help at r-project.org 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.
>
--
Felix Andrews / 安福立
http://www.neurofractal.org/felix/
More information about the R-help
mailing list