Skip to content
Back to formatted view

Raw Message

Message-ID: <57DC18C299094D4299F837570C5DF1C52B0F8FA923@EXWA-MBX01.nexus.csiro.au>
Date: 2010-04-20T00:41:53Z
From: Adrian Baddeley
Subject: convertion delaunay triangulation to SpatialPolygons

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
---------------------------

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")