I have a shapefile containing polygons. I would like to select all polygons within the layer that overlap with other polygons within the same layer.

The closest I have gotten is the Intersect tool in ArcMap. However, the problem with it is that, while it does find the overlapping polygons it also cuts them up and only keeps the parts of the polygons that overlap and not the whole polygon. I would like a tool that selects them and gives me the full polygons without cutting them.

I am using ArcPy.


I have managed to achieve this using the code below. The problem now is performance. Is there a better way of doing this or a way of improving the performance of this one?

    with arcpy.da.SearchCursor("lyr_existing_cadastre", ["OBJECTID"]) as search_cursor:
    for row in search_cursor:
        # Get the OBJECTID of row and use it to select row
        arcpy.SelectLayerByAttribute_management("lyr_existing_cadastre", "NEW_SELECTION",
                                                "\"OBJECTID\" = " + str(row[0]))

        # Copy row into a new feature class called row
            "lyr_existing_cadastre", "lyr_row", "NO_TEST")

        # Remove row from the input

        # Select all features that intersect with row and copy them into the row feature class
            "lyr_existing_cadastre", "INTERSECT", "lyr_row", selection_type="NEW_SELECTION")
            "lyr_existing_cadastre", "lyr_row", "NO_TEST")

        # If there is more than one feature in the row feature class
        # meaning there was something else in addition to row then delete those overlaps
        # from the input and append everything in row into the output feature class
        if (int(arcpy.GetCount_management("lyr_row").getOutput(0)) > 1):
                "lyr_row", "lyr_Overlapping_Polygons", "NO_TEST")
                "lyr_row", "lyr_Remaining_Polygons", "NO_TEST")

            "lyr_existing_cadastre", "CLEAR_SELECTION")
            "lyr_row", "CLEAR_SELECTION")
del search_cursor

You can Select By Location with your original shape as in_layer and your intersect output as select features.

Or you can use geodatabase topology which is very fast and will allow you to correct your input data without creating a new feature class. Create a file geodatabase and a feature dataset, export your shape to the feature dataset and create the topology:

enter image description here


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