1

I have a polygon layer with a number of features which overlap (in my case this wildfires in an area over time). I would like to clip the underlying features so there is no overlap. To elaborate I want to select the most recent feature (fire) and clip any portions of other features (older fires) which fall within the selection of my most recent feature (fire). I would then like to continue this process untill I have a layer with no overlapping polygons. How can I do this?

2
  • 1
    Welcome to GIS SE. As a new user, please take the Tour. Please Edit the Question to specify the GIS software in use,what you have tried, and where you are stuck.
    – Vince
    Commented Jun 13, 2022 at 12:41
  • Something that might work for me is Polygon self-intersection if I was able to set the feature order? Commented Jun 13, 2022 at 13:15

2 Answers 2

1

We had a similar problem with overlapping drainage areas for BMPs, where we wanted to retain the drainage area for one feature based on its attributes and remove the overlapping areas from the rest. Here's a simplified version of my script that should work for you (with some slight modifications), assuming you are working in ArcGIS.

import arcpy
import os

# Input polygon feature class or layer with overlapping features
polyInput = r"InputPolygon"
# Data field used to choose which overlapping polygon to keep
dataField = 'Year'

# Create a copy and a feature layer to make selections on
arcpy.env.addOutputsToMap = 1
arcpy.conversion.FeatureClassToFeatureClass(polyInput, arcpy.env.scratchGDB, 'PolygonCopy')
arcpy.env.addOutputsToMap = 0
arcpy.management.MakeFeatureLayer(os.path.join(arcpy.env.scratchGDB,'PolygonCopy'), 'polyLyr')

# Output FC and table to use with Count Overlapping
overlapFC = os.path.join(arcpy.env.scratchGDB,'overlapFC')
overlapTable = os.path.join(arcpy.env.scratchGDB,'overlapTable')
# Set minimum overlap count to 2
arcpy.analysis.CountOverlappingFeatures('polyLyr', overlapFC, 2, overlapTable)

# Get list of OIDs for overlapFC and loop through them
overlaps = [row[0] for row in arcpy.da.SearchCursor(overlapFC, "OBJECTID")]

for overlap in overlaps:    
    # Get the list of polygon OIDs for that overlap
    polys = [row[0] for row in arcpy.da.SearchCursor(overlapTable, "ORIG_OID",where_clause = 'OVERLAP_OID = '+str(overlap))]
    
    # Select them
    arcpy.management.SelectLayerByAttribute('polyLyr', 'NEW_SELECTION', "OBJECTID IN ({:s})".format(','.join(f"{x}" for x in polys)))
    
    # Extract data from selection as lists of OID and dataField
    rankOID  = [row[0] for row in arcpy.da.SearchCursor('polyLyr',"OBJECTID")]   
    rankData = [row[0] for row in arcpy.da.SearchCursor('polyLyr', dataField)]
    
    # Sort OIDs based on descending values of dataField (so the first OID is the most recent year in this example)
    clipOIDs = [x for _, x in sorted(zip(rankData, rankOID),reverse=True)]
    
    # Keep the desired OID, the remaining list will all be clipped
    keepOID = clipOIDs.pop(0)
    keepShape = [row[0] for row in arcpy.da.SearchCursor('polyLyr', "SHAPE@",where_clause = 'OBJECTID = '+str(keepOID))][0]
    
    # Loop through and clip
    with arcpy.da.UpdateCursor('polyLyr',"SHAPE@",where_clause="OBJECTID IN ({:s})".format(','.join(f"{x}" for x in clipOIDs))) as cursor:
        for row in cursor:
            oldShape=row[0]
            newShape=oldShape.difference(keepShape)
            cursor.updateRow((newShape,))
   
1
  • Unfortuantly I'm working QGIS Commented Jun 17, 2022 at 13:08
0

I've approached the problem with the Union-tool. First I created different shape-files for each Wildfire-year. In ArcPro it is possible to Rank the different fires-per-year per shapefile to Union.

Minor problem is that the outputfile let you down with a lot of 'null'values in columns and rows for Features where there is no overlap with. With Table-export to Excel I manually moved all the Feature-attributes to the same column in Excel. Then I imported the Excel-file to Table. With Join&Relate I joined the cleaned-Exceltable to the Features based on ObjectID.

It is some manual labor you have to put in, but its worth the shot. Let me know if you need a more step-by-step explanation.

I'm interested in suggestions which can script/automate the manual labor steps.

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.