Skip to content
Prev 8070 / 29559 Next

convertion delaunay triangulation to SpatialPolygons

Volkan Kepoglu wrote:

            
You can do this using the 'spatstat' package to construct the triangles 
(spatstat calls deldir to compute them) and the 'maptools' package to 
convert between spatstat and sp formats. See example below.

Adrian Baddeley
---------------------------

library(spatstat)
library(maptools)

x   <- c(2.3,3.0,7.0,1.0,3.0,8.0)
y   <- c(2.3,3.0,2.0,5.0,8.0,9.0)
df <- data.frame(x=x, y=y)

# need a boundary window so do one of the following:
W <- ripras(df, shape="rectangle")
W <- owin(c(0, 10), c(0, 10))

# create point pattern
X <- as.ppp(df, W=W)
plot(X)

# compute Dirichlet triangles
Y <- dirichlet(X)
plot(Y)

# convert
Z <- as(Y, "SpatialPolygons")