I have this layer structure in ArcMap:
"Localities, Gazeteers, Bases, Regions, and Territorial Claims are all Group Layers. All others under these are layers. I have a script that uses the Arcpy Describe
method to go under each layer and get its full directory path. Here is the script:
import arcpy
mxd=arcpy.mapping.MapDocument("CURRENT")
dataframes=arcpy.mapping.ListDataFrames(mxd)
for dataframe in dataframes:
for lyr in arcpy.mapping.ListLayers(mxd, "", dataframe):
if not lyr.isGroupLayer:
print(arcpy.Describe(lyr).catalogPath)
This would return something like: C:/Folder/Subfolder/layer.shp
Now, I am trying to figure out a way to get the path of each layer relative to the map. For example, for layer "features_multipoint"
, I need the script to report something like this:
MapDocument/Localities/Gazeteers/features_multipoint
The Describe method seems to not provide such capabilities.
Best Answer
Try
lyr.longName