Bruno Caram Muller
Bruno Caram Muller

Reputation: 85

How can I get the area of each Voronoi Polygon in R?

I have a set of coordinates X and Y for my points and used the deldir to create determine and plot the Voronoi Polygons. (I've used this tutorial here)

This is my plot: (sorry that its so small, but you get the idea). enter image description here

I need to determine the area of each polygon. How can I do that? I looked up in the deldirpackage page and couldnt find anything related to the Voronoi polygons, only about other

Upvotes: 3

Views: 1971

Answers (1)

www
www

Reputation: 39154

Based on the reference manual (https://cran.r-project.org/web/packages/deldir/index.html), the output of the deldir function is a list. One of the list element, summary, is a data frame, which contains a column called dir.area. This is the the area of the Dirichlet tile surrounding the point, which could be what you are looking for.

Below I am using the example from the reference manual. Use $ to access the summary data frame.

library(deldir)

x <- c(2.3,3.0,7.0,1.0,3.0,8.0)
y <- c(2.3,3.0,2.0,5.0,8.0,9.0)

dxy1 <- deldir(x,y)

dxy1$summary

Upvotes: 3

Related Questions