topo-unary-gDelaunayTriangulation: Compute Delaunay triangulation between points

Description Usage Arguments Details Value Author(s) References Examples

Description

Function to compute the Delaunay triangulation between points; only available for GEOS >= 3.4.0.

Usage

1
	gDelaunayTriangulation(spgeom, tolerance=0.0, onlyEdges=FALSE)

Arguments

spgeom

sp points object as defined in package sp

tolerance

Numerical tolerance value to be used in triangulation

onlyEdges

Logical, default returns triangles as polygons, if TRUE, returns a SpatialLines object with a single MULTILINESTRING

Details

When onlyEdges is TRUE, the SpatialLines object may be de-merged to identify the input points that are touched by each edge, making it possible to identify spatial neighbours.

Value

Either a SpatialPolygons object or a SpatialLines object containing a single Lines object of the undirected edges in the triangulation.

Author(s)

Roger Bivand

References

https://en.wikipedia.org/wiki/Delaunay_triangulation

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
if (version_GEOS0() > "3.4.0") {
library(sp)
data(meuse)
coordinates(meuse) <- c("x", "y")
plot(gDelaunayTriangulation(meuse))
points(meuse)
out <- gDelaunayTriangulation(meuse, onlyEdges=TRUE)
lns <- slot(slot(out, "lines")[[1]], "Lines")
out1 <- SpatialLines(lapply(seq(along=lns), function(i) Lines(list(lns[[i]]),
 ID=as.character(i))))
out2 <- lapply(1:length(out1), function(i) which(gTouches(meuse, out1[i],
 byid=TRUE)))
out3 <- do.call("rbind", out2)
o <- order(out3[,1], out3[,2])
out4 <- out3[o,]
out5 <- data.frame(from=out4[,1], to=out4[,2], weight=1)
head(out5)
## Not run: 
if (require(spdep)) {
class(out5) <- c("spatial.neighbour", class(out5))
attr(out5, "n") <- length(meuse)
attr(out5, "region.id") <- as.character(1:length(meuse))
nb1 <- sn2listw(out5)$neighbours
nb2 <- make.sym.nb(nb1)
}

## End(Not run)
}

Example output

rgeos version: 0.3-23, (SVN revision 546)
 GEOS runtime version: 3.4.2-CAPI-1.8.2 r3921 
 Linking to sp version: 1.2-3 
 Polygon checking: TRUE 

Loading required package: spdep
Loading required package: Matrix
Warning message:
In sn2listw(out5) :
  83, 84, 88, 93, 122, 123, 124, 132, 133, 134, 137, 139, 153, 154, 155 are not origins

rgeos documentation built on Dec. 15, 2021, 1:07 a.m.