[R-sig-Geo] convertion delaunay triangulation to SpatialPolygons

Adrian.Baddeley at csiro.au Adrian.Baddeley at csiro.au
Tue Apr 20 05:07:01 CEST 2010

Sorry, that should of course have read delaunay(X) not dirichlet(X)


From: Baddeley, Adrian (CMIS, Floreat)

Volkan Kepoglu wrote:

> how can i convert the delaunay triangulation to spatial polygons?

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


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)

# compute Dirichlet triangles
Y <- dirichlet(X)

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

More information about the R-sig-Geo mailing list