From Voronoi tessellation to Shapely polygons

后端 未结 4 1348
陌清茗
陌清茗 2020-12-24 08:11

from a set of points I built the Voronoi tessellation using scipy:

from scipy.spatial import Voronoi
vor = Voronoi(points)

Now I would like

4条回答
  •  攒了一身酷
    2020-12-24 09:06

    The function you implemented (order_vertices() ), cannot work in your case, because it simply takes a already ordered sequence of coordinates, which builds a rectangle, and inverts the direction of the polygon (and maybe works only with rectangles...). But you have a not ordered sequence of coordinates

    Generally speaking, you can not build a polygon from a arbitrary sequence of not ordered vertices because there is no a unique solution for concave polygons, as showed in this example: https://stackoverflow.com/a/7408711/4313133

    However, if you are sure that your polygons are always convex, you can build a convex hull with this code: https://stackoverflow.com/a/15945375/4313133 (tested right now, it worked for me)

    Probably you can build the convex hull with scipy as well, but I dint test it: scipy.spatial.ConvexHull

提交回复
热议问题