Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

calcVoronoi

Calculate the Voronoi (Dirichlet) Tesselation for a Set of Points


Description

Calculate the Voronoi (Dirichlet) tesselation for a set of points.

Usage

calcVoronoi (xydata, xlim = NULL, ylim = NULL, eps = 1e-09, frac = 0.0001)

Arguments

xydata

a data frame with columns X and Y containing the points.

xlim

range of X-coordinates; a bounding box for the coordinates.

ylim

range of Y-coordinates; a bounding box for the coordinates.

eps

the value of epsilon used in testing whether a quantity is zero.

frac

used to detect duplicate input points, which meet the condition abs(x1-x2) < frac*(xmax-xmin) and abs(y1-y2) < frac*(ymax-ymin).

Details

This routine ignores all columns other than X and Y.

If the user leaves xlim and ylim unspecified, the function defaults to the range of the data with each extent expanded by ten percent of the range.

This function sets the attribute projection to 1 and the attribute zone to NULL as it assumes this projection in its calculations.

Value

PolySet with columns PID, POS, X, and Y.

Author(s)

Nicholas M. Boers, Associate Professor – Computer Science
MacEwan University, Edmonton AB
Last modified Rd: 2013-04-10

See Also

Examples

local(envir=.PBSmapEnv,expr={
  oldpar = par(no.readonly=TRUE)
  #--- create some EventData
  events <- as.EventData(data.frame(
    EID=1:200, X=rnorm(200), Y=rnorm(200)), projection=1)
  #--- calculate the Voronoi tesselation
  polys <- calcVoronoi(events)
  #--- create PolyData to color it based on area
  polyData <- calcArea(polys)
  names(polyData)[is.element(names(polyData), "area")] <- "Z"
  colSeq <- seq(0.4, 0.95, length=4)
  polyData <- makeProps(polyData,
    breaks=quantile(polyData$Z,c(0,.25,.5,.75,1)),
    propName="col", propVals=rgb(colSeq,colSeq,colSeq))
  #--- plot the tesselation
  plotMap(polys, polyProps=polyData)
  #--- plot the points
  addPoints(events, pch=19)
  par(oldpar)
})

PBSmapping

Mapping Fisheries Data and Spatial Analysis Tools

v2.73.0
GPL (>= 2)
Authors
Jon T. Schnute [aut], Nicholas Boers [aut], Rowan Haigh [aut, cre], Alex Couture-Beil [ctb], Denis Chabot [ctb], Chris Grandin [ctb], Angus Johnson [ctb], Paul Wessel [ctb], Franklin Antonio [ctb], Nicholas J. Lewin-Koh [ctb], Roger Bivand [ctb]
Initial release
2021-01-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.