Hi!, I need to get the layer id within a map in ArcGIS Pro. It need to be done with Python, but can't find the way to do it. Any idea ? Impossible ?
Ah I see, yes you can get that:
aprx = arcpy.mp.ArcGISProject("CURRENT") m = aprx.listMaps()[0] lyrs = m.listLayers() for lyr in lyrs: print(lyr.getDefinition("V3").serviceLayerID)
Have a look at CIM access, it's quite useful, there is much more you can do with it besides this
That was it! thanks!
Thanks for the info, but that "id" is just the order within the project. I look to get the ID that is attached to the layer within the properties.
Take a look at arcpy.mp, I think this gets you what you want:
aprx = arcpy.mp.ArcGISProject("CURRENT") m = aprx.listMaps()[0] lyrs = m.listLayers() [(i, lyr.name) for i, lyr in enumerate(lyrs)]
returns
[(0, 'TestLine'), (1, 'TestPoint'), (2, 'TestPoint_Raster'), (3, 'TestPoly'), (4, 'TestPoint'), (5, 'World Topographic Map'), (6, 'World Hillshade')]
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.