I will often create many temporary layer files with MakeFeatureLayer_management
. I was wondering if there was a means to list the temporary layer files I've created. I've tried setting the workspace to "in_memory"
and applying ListDatasets ()
and ListFiles ()
, but since these layers don't seem to actually be stored in "in_memory"
, this doesn't produce my desired results. Is there another location these files are stored that I can access? it would be nice to just be able to list all my created layers and delete them without having to keep track of each, to free up locks and what have you.
Answer
This worked for me:
import arcpy
contours = r'C:\TEMP\Contours.shp'
con2 = r'C:\TEMP\Contours2.shp'
d = {'a': 1, 'b': 2}
_list = [1,2,3]
string = 'test'
lyr1 = arcpy.MakeFeatureLayer_management(contours, 'contours1').getOutput(0)
lyr2 = arcpy.MakeFeatureLayer_management(con2, 'contours2').getOutput(0)
layers = [globals()[v] for v in dir() if isinstance(globals()[v], arcpy.mapping.Layer)]
print layers
for lyr in layers:
print lyr.dataSource
[
However, when you call the make feature layer function it is always made from an existing feature class or shapefile.
No comments:
Post a Comment