I have a forested area, that suffered different disturbances over multiple years. Each year, disturbance data was collected on different forest extend and some disturbances can overlap (beetle infestation or clear-cut).
My goal is to clean and summarize the dataset, i.e. unify the extent and allow the forest area to be disturbed only once over my time period. Simply, I wish to clip the disturbance data to the available forest area in current year, and update the extend of forest cover after every disturbance.
I am trying to apply
arcpy to automate the process.
- read forest area & list yearly disturbances
- create for loop to loop through list of disturbances
- clip disturbance by available forest
- update available forest by erasing the disturbance from current forest cover
- do the same for next disturbance
I thought this could be fairy simple to do. However, my script either return empty dataset, erase the initial forest or says "that output and input data equals".
My desired output is the set of cleaned (not overlapping disturbances limited on forest) disturbances. I am trying to automate the process, as I have 3 different disturbances types over multiple years, together 18 disturbances featureclasses.
How to update the forest polygon and spatially restrict every disturbance?
import arcpy import os # Allow files to overwrite arcpy.env.overwriteOutput = True # Define directories path = "U:\\project\\analyzed" arcpy.env.workspace = os.path.join(path, "analyzed.gdb") outWD = os.path.join(path, "cleaned.gdb") aoi = "aoi_fin_03" # Read all disturbance data disturbLs = arcpy.ListFeatureClasses() # Intersect available forest with disturbances in each year, # update forest cover for dist in disturbLs: # Clip the disturbance to forest extend outClip = os.path.join(outWD, dist) arcpy.Clip_analysis(dist, aoi, outClip) # Update available forest cover by erasing current disturbance updAoi = "in_memory\layer" + aoi arcpy.CopyFeatures_management(aoi, updAoi) arcpy.Erase_analysis(updAoi, outClip, aoi) #Delete in memory files to avoid the lock arcpy.Delete_management("in_memory")