1

We have some set of point coordinates in lat/long which contribute to a polygon. From this set how do we determine the polygon is clockwise or anticlockwise?

Chris W
  • 15,720
  • 2
  • 29
  • 47
Tushar Nimkar
  • 51
  • 1
  • 6
  • 1
    Given that there are valid cases where a single polygon can be counter clockwise, there's no real way to tell if a polygon is 'clockwise' or 'counterclockwise' without some level of implied knowledge. However, what you're looking for is the 'envelope angle' of your polygon. If it's greater than 90°, then it's 'counterclockwise', otherwise 'clockwise'. Depending on your platform, there are different ways of finding this out. One way would be to ensure that all your data is stored in a valid format before sending it to the client. – nagytech Jun 09 '15 at 12:39
  • 1
    @nagytech No, it is trivial to determine ring orientation -- Calculate the area using the trapezoid rule (or zipper algorithm); negative area is opposite orientation of positive area – Vince Jun 09 '15 at 12:59
  • 1
    Check again, I never said any operation was non-trivial. Regardless, calculating the envelope angle is immensely more efficient than calculating the area of a polygon. – nagytech Jun 09 '15 at 13:25
  • You wrote "there's no real way to tell if a polygon is 'clockwise' or 'counterclockwise' without some level of implied knowledge", which is incorrect. – Vince Jun 09 '15 at 18:50
  • Here is a discussion on stack overflow. – Hornbydd Jun 09 '15 at 22:30
  • Related: http://gis.stackexchange.com/q/62884 http://gis.stackexchange.com/q/3729 http://gis.stackexchange.com/q/119150 -- however, I hope that someone adds an answer describing the algorithms available for this fundamental GIS concept, so that this could be made into a canonical Q&A. – blah238 Jun 10 '15 at 03:31

0 Answers0