geo_voronoi: Create a voronoi tiling 'geom'

View source: R/geo_voronoi.R

geo_voronoiR Documentation

Create a voronoi tiling geom

Description

Create a voronoi tiling geom

Usage

geo_voronoi(crds = NULL, window = NULL, features = 3)

Arguments

crds

data.frame(2)
Coordinates to build the geom from. It must include the column names x and y.

window

data.frame(2)
in case the reference window deviates from the bounding box of crds, specify here the minimum and maximum values in columns x and y.

features

integerish(1)
number of tiles to sketch.

Value

A geom.

See Also

Other tilings: geo_tiles()

Examples

# 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 <- geo_point(crds = coords, window = window)
geo_vis(voronoi = aGeom, linecol = "deeppink")

tiles <- geo_voronoi(crds = coords, window = window)
geo_vis(tiles, new = FALSE)

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

EhrmannS/geometr documentation built on Jan. 31, 2024, 9:13 a.m.