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
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to