voronoi: Simple and weighted Voronoi tesselations

Description Usage Arguments Value Examples

View source: R/polygonprocessing.R

Description

Function to produce a Voronoi tesselation (aka Dirichelet set or Thiessen polygons) from a set of point, with or without weights.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
voronoi(
  x,
  ids,
  weights = NULL,
  win = NULL,
  maxdist = NULL,
  nsteps = 36,
  verbose = TRUE,
  ...
)

Arguments

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.

Value

An object of class SpatialPolygonsDataFrame

Examples

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

ahb108/sparch documentation built on Feb. 3, 2021, 1:21 a.m.