fortify_voronoi: Create Data Frame from voronoi_polygons output

Description Usage Arguments Examples

View source: R/fortify_voronoi.R

Description

Allows output of voronoi_polygon to be plotted using geom_polygon.

Usage

1
fortify_voronoi(vor_spdf)

Arguments

vor_spdf

Output from voronoi_polygon (SpatialPolygonsDataFrame)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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))

garretrc/ggvoronoi documentation built on May 7, 2019, 9:36 a.m.