I am using ArcGIS Desktop 10.6, basic license, Spatial Analyst, python 2.6, 2019 AD.

I have a polygon feature class with representing a lake, with multiple features overlapping (all in the same feature class). The shoreline feature covers the entire area of the lake, the 1 foot depth feature covers all of the area at 1 foot, etc, etc. Opening an editing session and starting at the deepest depth, I can use the Editor toolbar Clip function to clip each area from the others. The end result is a flat representation of the lake, no overlapping depths.

To accomplish this with arcpy, I think I need to sort my list descending from the largest depth and clip the below features. I've attached a sample feature class that this script would intake, and another ("flat") that should be output.

import arcpy
from arcpy import env

    # Set workspace environment
    env.workspace = "C:/data/default.gdb"

    # intake lake
    in_dataset = arcpy.GetParameterAsText(0)

    # sort the lake attribute table by the depth
    sort_fields = ["depth", "DESCENDING"]

    # Use Peano algorithm
    sort_method = "PEANO"

    # sort the fc, run Editor Clip on each attribute, starting with the largest
    arcpy.Sort_management(in_dataset, sort_fields, sort_method)

    with arcpy.da.SearchCursor(in_dataset, 'SHAPE@') as cursor:
        for row in cursor:
            #don't know how to call this part
            EditorClipTool(row, "DISCARD")

    print arcpy.GetMessages()

except arcpy.ExecuteError:
    # Print error messages
    print arcpy.GetMessages(2)

except Exception as ex:
    print ex.args[0]

input: https://drive.google.com/open?id=1ShZ5OQensnskLbgIzMWroVM2GIKLukou

desired output: https://drive.google.com/open?id=1QLbLr30yY136wvAUaEXEHSrM33ZKR3cG

  • Use difference method for geometry, e.g. gis.stackexchange.com/questions/293433/…
    – FelixIP
    Jun 2, 2019 at 3:07
  • @FelixIP unfortunately this is happening inside one feature class
    – rrrrrrrr
    Jun 3, 2019 at 16:41
  • It doesn't matter at all.
    – FelixIP
    Jun 3, 2019 at 20:23
  • @FelixIP Can you explain further? I am unclear on how to implement this. Can I call the next row in a cursor somehow and then use shp.difference?
    – rrrrrrrr
    Jun 3, 2019 at 21:16

1 Answer 1


Use this on a sorted copy of your polygons:

import arcpy
## works on sorted table !!!
with arcpy.da.UpdateCursor("POLYGONS","Shape@") as cursor:
    for row in cursor:
        if N==len(geomList):break

Original, 1st record selected

enter image description here

Result, 1st record selected

enter image description here

  • I have no idea how this works but it does great. I will post updated working code when I get it cleaned up.
    – rrrrrrrr
    Jun 4, 2019 at 0:34
  • If it works, please mark as solved.
    – FelixIP
    Jun 4, 2019 at 7:21

Your Answer

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

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