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

Adrian.Baddeley at csiro.au Adrian.Baddeley at csiro.au
Tue Apr 20 02:41:53 CEST 2010


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


More information about the R-sig-Geo mailing list