0

I have a set of 2D points and some box that bounds all the points. I would like to have each point's nearest neighbor region as a Polygon (shapely) object, with no polygon stepping out the bounding box. Is it possible?

buffer = 10
points = np.random.rand(1,100, (20,2))

# bounding box
xmin, ymin = points.min(axis=0) - buffer
xmax, ymax = points.max(axis=0) + buffer

vor    = scipy.spatial.Voronoi(points)
# scipy.spatial.voronoi_plot_2d(vor) # <- How to get each region as shapely polygon??
Amir
  • 83
  • 1
  • 8
  • That does partially answer the question, thanks. But how to get a polygon bounded by box for the points with infinite are regions? – Amir Jan 31 '20 at 20:42
  • IIUC, this should be relatively simple using such functions as [`difference`](https://shapely.readthedocs.io/en/latest/manual.html#object.difference) and [`union`](https://shapely.readthedocs.io/en/latest/manual.html#object.union) of Shapely. – Georgy Jan 31 '20 at 22:07

0 Answers0