gs_voronoi: Create a voronoi tiling 'geom'

Description Usage Arguments Value See Also Examples

View source: R/gs_voronoi.R

Description

Create a voronoi tiling geom

Usage

1
gs_voronoi(anchor = NULL, window = NULL, features = 3, ...)

Arguments

anchor

[geom(1)|data.frame(1)]
Object to derive the geom from. It must include column names x, y and optionally a custom fid.

window

[data.frame(1)]
in case the reference window deviates from the bounding box of anchor (minimum and maximum values), specify this here.

features

[integerish(1)]
number of tiles to sketch.

...

[various]
graphical parameters to gt_locate, in case the tiling is sketched; see gpar.

Value

A geom.

See Also

Other tilings: gs_tiles()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# 1. create voronoi polygons programmatically
coords <- data.frame(x = c(40, 70, 70, 50),
                     y = c(40, 40, 60, 70))
window <- data.frame(x = c(0, 80),
                     y = c(0, 80))
aGeom <- gs_point(anchor = coords, window = window)
visualise(voronoi = aGeom, linecol = "deeppink")

tiles <- gs_voronoi(anchor = aGeom)
visualise(tiles, new = FALSE)

# 2. sketch a voronoi polygon
if(dev.interactive()){
  tiles <- gs_voronoi()
  visualise(tiles, new = FALSE)
}

geometr documentation built on Sept. 21, 2021, 1:07 a.m.