Select to view content in your preferred language

Delete all Feature Layers in Memory

1739
3
Jump to solution
03-17-2022 09:40 AM
jaykapalczynski
Honored Contributor

I am running a script that has many Features added.  Up until now the script would run and then end and be done but I am adding a WHILE loop that reruns the script.

In this script there are a bunch of Feature Layers that get created like below.

At the end of the Script before it runs again I want to DELETE all of the FeatureLayers that were created in memory... Is there a call that will do the delete.

 

target_lyr = arcpy.MakeFeatureLayer_management(os.path.join(db['Path'], layer), layer+'_exclude')

 

0 Kudos
1 Solution

Accepted Solutions
DonMorrison1
Frequent Contributor

Try this (for each layer):

 arcpy.Delete_management(target_lyr)

 

View solution in original post

3 Replies
AlfredBaldenweck
MVP Regular Contributor

So, you want to get rid of interim files that you don't need anymore?

Create an empty list and append the interim files to it as they're created. Then run a FOR loop through the list, deleting each file in the list.

0 Kudos
DonMorrison1
Frequent Contributor

Try this (for each layer):

 arcpy.Delete_management(target_lyr)

 

jaykapalczynski
Honored Contributor

Yea I was thinking that....but was wondering if at the end of the script I could just DELETE ALL or something like that...like clearing the Cache on your browser

0 Kudos