calcVoronoi: Calculate Voronoi Tesselation

View source: R/PBSmapping.r

calcVoronoiR Documentation

Calculate Voronoi Tesselation

Description

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

Usage

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

.expandEdges(polys, pts, xlim, ylim)

Arguments

xydata

numeric – data frame with columns X and Y containing the points.

xlim

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

ylim

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

eps

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

frac

numeric – used to detect duplicate input points, which meet the condition \left | x1 - x2 \right | < \mbox{frac} \times (\mbox{xmax} - \mbox{xmin}) \mbox{and} \left | y1 - y2 \right | < \mbox{frac} \times (\mbox{ymax} - \mbox{ymin})

polys

numeric – valid PolySet data frame

pts

numeric – data.frame with 'X' and 'Y' columns

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'.

Auxiliary dot function '.expandEdges' returns an expanded 'PolySet'.

Author(s)

Nicholas M. Boers, Software Engineer, Jobber, Edmonton AB

Maintainer: Rowan Haigh, Program Head – Offshore Rockfish
Pacific Biological Station (PBS), Fisheries & Oceans Canada (DFO), Nanaimo BC
locus opus: Remote office, Vancouver BC
Last modified Rd: 2024-09-03

See Also

In package PBSmapping:
addPoints, addPolys, calcArea, calcCentroid, calcConvexHull, calcMidRange, calcSummary, locateEvents, plotMap, plotPoints, plotPolys, PolySet

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 documentation built on Sept. 30, 2024, 9:21 a.m.