[R-sig-Geo] voronoi (thiessen) polygons inside irregular area

Josh Firth joshfirth at hotmail.com
Thu Jan 23 09:38:28 CET 2014


Rolf Turners solution to Dirichlet-Voronoi-Thiessen polygons in an irregular
area, by elimination from each tile any polygons that do not contain any
points of the pattern, allows a rough determination of first order
neighbours. This is currently the best option for me. However, it will
suffer if the areas of the polygons are needed, or if the overlaying polygon
has holes, and could also sometimes miss first order neighbours e.g. if in
the first example given, the points of interest were sometime like:
     x<-c(0.9,1.7,2.4,2.9,4.83, 0.73, 2.6, 3.69, 4.23, 2.86, 1.91, 4.32,
4.60, 1.82,0.5)
    y<-c(1.9,0.9,2.8,1.9,1.81, 1.66, 4.7, 5.66, 1.99, 4.03, 4.32, 5.98,
5.56, 3.41,5.5)

and the polygon was

x.p<-c(0.1, 6.0, 6.0, 0.1, 5.0, 3.0, 3.5, 0.1)
y.p<-c(0.1, 1.0, 6.5, 5.5, 5.0, 1.0, 4.8, 5.0) 

then following the previous code given:

poly.l<-list(x.p,y.p)
names(poly.l)<-c("x","y") 
poly.w.points<-ppp(x=x,y=y,poly=poly.l)
spatstat.options("gpclib"=T)

and applying Rolf turner's function

bar <- function(X) {
require(spatstat)
ttt <- dirichlet(X)
sss <- ttt$tiles
f <- function(x,pat){
     www <- lapply(x$bdry,function(y){owin(poly=y)})
     gp  <- sapply(www,function(w){
                any(inside.owin(pat$x,pat$y,w))})
     www[[seq(along=gp)[gp]]]
}
rrr <- lapply(sss,f,pat=X)
ttt$tiles <- rrr
ttt
} 
junk <- bar(poly.w.points)
junk.sp <- as(junk,"SpatialPolygons")
nays <- poly2nb(junk.sp)
nays[8]

shows that 8 is not a first order neighbour with 15, even though it would be
desirable that they are:
plot(junk)
text(x,y,1:length(x))

Adrian Baddeley also points out that a completely different algorithm (not
currently available in R?) may be the best route. Would another potential
solution be to split (using more thiessen polygons) the area of polygons
that DO NOT contain a 'point of interest' to belong to surrounding polygons
that DO contain a point of interest? 

Any suggestions of potential methods to achieve (even if imperfectly) the
final goal of 'Dirichlet-like' tiles within an irregular area are much
appreciated!

Josh Firth











--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/voronoi-thiessen-polygons-inside-irregular-area-tp7584761p7585612.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list