How can I get the area of each polygon of a voronoi diagram?

Illustration
NILESH PANDEY - 2023-03-23T14:27:56+00:00
Question: How can I get the area of each polygon of a voronoi diagram?

I need to find areas of all the polygons inside a voronoi diagram and then alot diffrent properties based on different areas. I know the co-ordiantes of all the polygons but cannot distinguish between the ones forming the specific polygon  

Expert Answer

Profile picture of Kshitij Singh Kshitij Singh answered . 2025-11-20

x = rand(10,1) ;  y = rand(10,1) ;
[v,c] = voronoin([x y]) ;

figure
hold on
voronoi(x,y)
A = zeros(length(c),1) ;
for i = 1:length(c)
    v1 = v(c{i},1) ; 
    v2 = v(c{i},2) ;
    patch(v1,v2,rand(1,3))
    A(i) = polyarea(v1,v2) ;
end

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!