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?

  • 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 9 '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 9 '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 9 '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 9 '15 at 18:50
  • Here is a discussion on stack overflow. – Hornbydd Jun 9 '15 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.