Description Usage Arguments Value Examples
View source: R/polygonprocessing.R
Function to produce a Voronoi tesselation (aka Dirichelet set or Thiessen polygons) from a set of point, with or without weights.
1 2 3 4 5 6 7 8 9 10 |
x |
an object of class SpatialPoints* |
ids |
identifiers for each point as lables for the resulting polygons |
weights |
optional weight values for the calculation (e.g. measure of relative ‘influence’ or ‘size’ of each point) |
win |
an object of class SpatialPolygons* for the exterior of the study area. |
maxdist |
A cut-off (the radius of a circle) for the extent of a point's tesselation. |
nsteps |
How many increments to use for defining the cruvature of a circle. |
verbose |
A logical variable indicating whether extra information on progress should be reported. Default is TRUE. |
An object of class SpatialPolygonsDataFrame
1 2 3 4 5 6 7 8 9 10 | w <- SpatialPolygons(list( Polygons(list(Polygon(cbind(c(0,0,100,100,0), c(0,100,100,0,0)))), "1")), 1:1)
pts <- data.frame(X=runif(3)*100,Y=runif(3)*100,ptID=letters[1:3], Size=c(1,2,4))
coordinates(pts) <- ~X+Y
vor <- voronoi(pts, ids=pts$ptID, win=w)
vorw <- voronoi(pts, ids=pts$ptID, weights=pts$Size, win=w)
plot(vor, lty="dotted", border="red")
plot(vorw, border="blue", add=TRUE)
points(pts)
text(coordinates(pts)[,1],coordinates(pts)[,2], pts$Size, col="blue", adj=c(1,-1))
legend("center", lty=c("dotted","solid"),col=c("red","blue"),legend=c("unweighted","weighted"), bty="n")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.