Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

How to get information about layers using Arcpy

$
0
0

I have this layer structure in ArcMap:

enter image description here

“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.


Viewing all articles
Browse latest Browse all 767

Trending Articles