Clipping Voronoi vessels (pysal.cg.voronoi)

101 views Asked by At

straight to the problem: given these points

[[ 77.51 254.19], [ 75.32 184.45], [ 88.57 83.43], [153. 135. ], [196.62 55.78]]

and a polygon that defines the bounding box, which should be covered entirely by voronoi tessels: [230 0; 230 370; 0 370; 0 0; 230 0]

I use this code to perform Voronoi tessellation:

from libpysal.cg.voronoi  import voronoi, voronoi_frames

points = np.array(self.__get_coordinates())
bb = box(self.min_x, self.min_y, self.max_x, self.max_y)
region_df, point_df = voronoi_frames(points, clip=bb)

fig, ax = plt.subplots()
plt.plot(*bb.exterior.xy,lw=3)
region_df.plot(ax=ax, color='white', edgecolor='black', lw=3)
point_df.plot(ax=ax, color='red')

where min_x=0,min_y=0,max_x=230,max_y=370. Unfortunately I obtain this result

enter image description here

which is not correct as the upper polygon do not cover the remaining part of the bounding box.

Any idea on how to fix this?

Thanks :)

0

There are 0 answers