Skip to content
Prev 308813 / 398503 Next

Creating a polygon from an unordered set of points

One possibility:

Estimate the center of the polygon with the mean of the x coords and
the mean of the y coords.
Calculate the angle of each point from that center point using the
atan2 function
sort the data by the angle calculated.

This will not be perfect if you have inlets and peninsulas, but would
at least get you started and those points could be adjusted by hand or
by an algorithm that looks for crossings/self-intersections and
reverses the order of the points that cause the cross.
On Tue, Oct 23, 2012 at 11:50 AM, peleve <pitiur at gmail.com> wrote: