sf_voronoi_diagram | R Documentation |
Generates Voronoi diagram (Thiessen polygons) for sf object
sf_voronoi_diagram(sfj)
sfj |
An |
An sf
object of polygon geometry type or can be converted to this by sf::st_as_sf()
.
Only sf objects of (multi-)point type are supported to generate voronoi diagram and the returned result includes only the geometry column.
pts = sf::read_sf(system.file('extdata/pts.gpkg',package = 'sdsfun'))
pts_v = sf_voronoi_diagram(pts)
library(ggplot2)
ggplot() +
geom_sf(data = pts_v, color = 'red',
fill = 'transparent') +
geom_sf(data = pts, color = 'blue', size = 1.25) +
theme_void()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.