I am using ArcPy in ArcGIS 10.1 to process some geometry using the arcpy.da data access module.

However I have run into a problem with complex Polygons that contain inner rings/holes.

From the documentation in ArcGIS and this question I can detect rings via the None objects in the Point array.

But now I need to know whether these rings are clockwise or counter-clockwise so that I can tag them as inner or outer.

Is there an ArcPy function I can use to detect the rings' directions?

2 Answers 2


How about this snippet? From PySAL source code.

Pass in a list of vertices in the form [(x1,y1), (x2,y2), ..., (xn, yn)]. Returns true or false.

def is_clockwise(vertices):
    if len(vertices) < 3:
        return True
    area = 0.0
    ax, ay = vertices[0]
    for bx, by in vertices[1:]:
        area += ax * by - ay * bx
        ax, ay = bx, by
    bx, by = vertices[0]
    area += ax * by - ay * bx
    return area < 0.0

If you run the Multipart_to_Singlepart tool first, all the geometries that have partCount > 1 will have inner rings. Using ArcPy scripting to read the geometry, the outer ring is returned as the first part, the remaining parts are then holes. You shouldn't need to analyse the ring orientation to figure this out.

  • Based on this question and related info at this other question, I do not believe this is correct. You can have a singlepart polygon with a hole whose part count is 1. Parts are distinct from rings.
    – Chris W
    Feb 17, 2015 at 21:59
  • 1
    @ChrisW, you are correct. My testing was flawed somehow. However, I discovered this will detect single-part polygons that have a hole, !Shape!.boundary().partCount >1.
    – klewis
    Sep 12, 2016 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.