I have list of Lat long that form a polygon around a center point. I would like to get ordered List of Lat-Long clockwise so as to connect Lat-Long Vertices in that ordered list and form non-convex polygon.
Asked
Active
Viewed 746 times
0
-
StackOverflow is not *I want that, give me code* site. What have you tried so far? Where did you get stuck? – MarcinJuraszek Jun 25 '14 at 05:57
-
I m trying to understand how set of Lat and Long as a list of points can be used to form polygon. what are possible ways to solve this ? – user1701450 Jun 25 '14 at 06:01
1 Answers
2
The generation of a polygon from a set of vertices is ill-defined, as can be seen in the following example.
Let
A = ( 0, 0)
B = ( 3,-3)
C = ( 6,-1)
D = ( 4,-1)
E = ( 4, 1)
F = ( 6, 1)
G = ( 3, 3)
One possibility to form a polygon clockwise is
A-G-F-E-D-C-B-A
and the ordering
A-G-E-F-C-D-B-A
is a different one. The first polygon is concave and the second aon is convex. If A
is removed and the remaining points are mirrored at the axis G-B
, it is even possible to define two non-convex polygons from the given set of vertices. More precisely,
the set of vertices would be
B = ( 3,-3)
C = ( 6,-1)
D = ( 4,-1)
E = ( 4, 1)
F = ( 6, 1)
G = ( 3, 3)
E' = ( 2, 1)
F' = ( 0, 1)
D' = ( 2,-1)
C' = ( 0,-1)
and the two different polygons are
G-E-F-C-D-B-C'-D'-E'-F'-G
and
G-F-E-D-C-B-D'-C'-F'-E'-G
.
However, if one ins interested in the convex hull polygon (the boundary of the convex hull) of the given vertices, there are many different algorithms to compute it.

Codor
- 17,447
- 9
- 29
- 56
-
1or in simple words, as anyone that tried to solve a connect-the-dot puzzle as a kid - to draw a poligon, the order of the dots is critical. – Zohar Peled Jun 25 '14 at 06:35
-
@ZoharPeled Thanks for the straightforward reformulation. However I wanted to provide a specific example which has few vertices, covers all cases and uses only non-intersecting edges. – Codor Jun 25 '14 at 06:37
-
Thanks for your suggestions. I would like to know how would this apply when these vertices are defined with spatial co-ordinates(lat/long) ? – user1701450 Jun 25 '14 at 15:00
-
@user1701450 I don't understand your comment, in the example above the vertices _are_ given with spatial coordinates - or do you mean something different? – Codor Jun 25 '14 at 15:10
-
I mean I have set of lat n long coordinates and I am ordering it. can you please provide some pseudo code to implement the approach you explained above and order the points when joined form closed polygon ? – user1701450 Jun 25 '14 at 15:56