mwVoronoi: Multiplicatively-weighted Voronoi Polygons

View source: R/mwVoronoi.R

mwVoronoiR Documentation

Multiplicatively-weighted Voronoi Polygons

Description

Calculate a multiplicatively-weighed Voronoi diagram, where distances are divided by some per-observation weight. On planar an spherical topologies all segments are circles and segments thereof (or straight lines if observations with equal weights exist), with the radii of the circles corresponding to \frac{r_e}{4}\left(\frac{w_p}{w_p + w_q}\right), with r_e corresponding to earth's radius. The circle is positioned such that (1) it encompasses the point of interest and (2) the point immediately between p and q lies at \ell_{pq} \left(\frac{w_p}{w_p + w_q}\right) units away from p with \ell_{pq} being the distance between p and q, and (3) oriented with this point normal to the geodesic between p and q.

Usage

mwVoronoi(
  xy,
  w,
  tolerance = 7,
  prec = 100,
  clip = NULL,
  x = "lon",
  y = "lat",
  topology = "geoid",
  a = 6378137,
  f = 1/298.257223563,
  pb = FALSE
)

Arguments

xy

Something coercible to a SpatVect points object and with at least two observations. The point locations of interest. Units must be degrees longitude for x and degrees latitude for y when topology is either 'geoid' or 'sphere'. In the future lines and polygons will be supported

w

A vector of equal length to xy. The weights corresponding to each point

tolerance

How many digits of the lonlat coordinates are kept (to avoid floating point errors?). Default is tolerance = 7

prec

How many segments does each ellipsoid contain? Default is prec = 72, or one every five degrees

clip

An object of class null, logical, or coercible to a SpatExtent. Should the output polygons encompass the whole world (the default, clip = NULL)? If not, clip = TRUE crops them to the extent of the input points, while passing an object with a SpatExtent will crop them by such an extent.

x

A character vector indicating the column with 'x' coordinates. Ignored if xy is a SpatVect points object.

y

A character vector indicating the column with 'y' coordinates. Ignored if xy is a SpatVect points object.

topology

One of 'geoid', 'spherical', or 'planar', corresponding to the underlying topology.

a

Equatorial radius. Default is for WGS84. Ignored if topology is not 'geoid'.

f

Ellipsoidal flattening. Default is for WGS84. Ignored if topology is not 'geoid'.

pb

Logical. Should a progress bar be displayed? Default is pb = FALSE

Details

See also makeCatchment

Value

A SpatVector containing the Voronoi polygons for each input observation

Examples


set.seed(3755)
# Create dummy observations
obs <- data.table(lon = runif(25, -180, 180),
                  lat = runif(25, -90, 90),
                  N = runif(25, 0, 100))
                  
mwv <- mwVoronoi(obs[,1:2], w = obs$N)

andresgmejiar/lbmech documentation built on Feb. 2, 2025, 12:37 a.m.