voronoi_polygon.Rd
Taken from https://cran.r-project.org/src/contrib/Archive/ggvoronoi/ggvoronoi_0.8.4.tar.gz directly since it is a standalone function and the dependency on ggvoronoi is messing up R CMD CHECK
voronoi_polygon(data, x = "x", y = "y", outline = NULL, data.frame = FALSE)
data.frame
containing a set of points to make voronoi regions and any additional desired columns.
numeric vector (for example longitude).
numeric vector (for example latitude).
data.frame
with first column x/longitude, second column y/latitude, and a group column denoting islands or pieces.
output as data.frame
? You will lose information if you do this. For use in StatVoronoi
.
Create a Voronoi diagram for analysis or plotting with geom_polygon
.
if (FALSE) {
set.seed(45056)
x <- sample(1:200,100)
y <- sample(1:200,100)
points <- data.frame(x, y,
distance = sqrt((x-100)^2 + (y-100)^2))
circle <- data.frame(x = 100*(1+cos(seq(0, 2*pi, length.out = 2500))),
y = 100*(1+sin(seq(0, 2*pi, length.out = 2500))),
group = rep(1,2500))
vor_spdf <- voronoi_polygon(data=points,x="x",y="y",outline=circle)
vor_df <- fortify_voronoi(vor_spdf)
ggplot(vor_df) +
geom_polygon(aes(x=x,y=y,fill=distance,group=group))
}