[R-sig-Geo] Finding to which Voronoi/Dirichlet a point belongs to

Paul Hiemstra p.hiemstra at geo.uu.nl
Mon Oct 12 16:57:04 CEST 2009


Hi Pierre,

When you load the output of tripack into a SpatialPolygons object (see 
the sp-pacakge on CRAN), you can use the overlay() function.

cheers,
Paul

Pierre Roudier wrote:
> Dear list,
>
> I am trying to use the Voronoi tesselation of a point pattern to predict
> values of a second one.
>
> This is what it looks like:
>
> I got a first population of points :
>
> x <- runif(100)
> y <- runif(100)
> my.data.set <- data.frame(cbind(x,y))
>
> The second population is a subsample of the first one:
>
> spl.data.set <- my.data.set[1:20,]
> spl.data.set$z <- rnorm(20)
>
> plot(my.data.set$x,my.data.set$y)
> points(spl.data.set$x,spl.data.set$y,pch='+',col='red')
>
> I want to interpolate the values of my.data.set using the tesselation of
> spl.data.set:
>
> require(spatstat)
> spl.ppp <-
> as.ppp(spl.data.set,c(range(my.data.set$x),range(my.data.set$y)),marks=spl.data.set$z)
> spl.dir <- dirichlet(spl.ppp)
> plot(spl.dir,add=TRUE)
>
> To do that, I have to identify, for which point of my.data.set, to which
> voronoi tile it belongs to.
>
> Using spatstat, I can just extract to which tile belongs each point, using
> an ugly double loop, and without possibility to find back the value of the
> center of each voronoi cell:
>
> require(spatstat)
> tiles.id <- vector(mode="numeric",length=nrow(my.data.set))
> spl.tiles <- tiles(spl.dir)
> for (i.pt in 1:nrow(my.data.set)) {
>    for (i.tile in 1:length(spl.tiles)){
>       curr.tile <-spl.tiles[[i.tile]]
>       if ( inside.owin(my.data.set$x[i.pt],my.data.set$y[i.pt],curr.tile) )
> {
>          tiles.id[i.pt] <- i.tile
>       }
>    }
> }
>
> Using tripack, I would know how to retrieve the centre of a tile and go back
> to the original value (using cells() function), but unfortunately it misses
> an equivalent to inside.owin().
>
> Does any spatstat/tripack/other package user has an idea about it?
>
> Thanks,
>
> Pierre
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>   


-- 
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul



More information about the R-sig-Geo mailing list