UdiM
UdiM

Reputation: 524

Get polygon from unordered points

Im using Shapely library to deal with polygons. It has class called Polygon which gets an ordered set of coordinates and turns them into a polygon.
The problem is that I got set of unordered coordinates. I want polygon which wraps all of the points.

I have been looking into Shapley documentation, but I can't find any information about how to do it

Is there an algorithm to order the points before sending them to Polygon? Or is there another method I can do that?

Upvotes: 5

Views: 3401

Answers (1)

Hicham Zouarhi
Hicham Zouarhi

Reputation: 1060

You can create a convex hull around the points but it will not ignore the points that are inside the hull

example from https://shapely.readthedocs.io/en/latest/manual.html#object.convex_hull

MultiPoint([(0, 0), (1, 1)]).convex_hull

Upvotes: 8

Related Questions