I am working in an ArcMap session, I've checked the option to get an ID for each of the layers in my document, so anyone has it.

enter image description here

Now, what I need is a way to get these values within a python script (to copy that automatically in a table): there's no such information in the layer's properties reached by a describe, nor from the .mapping module.

  • 4
    The property DSID in arcpy.describe returns the ID of the data set. have you tried that? An example would be desc = arcpy.Describe("some layer") then desc.DSID
    – risail
    Jan 4, 2016 at 13:44
  • What version of ArcGIS are you using?
    – crmackey
    Jan 4, 2016 at 17:34
  • Hy Dan, the problem is that I need the ID of a layer, which doesn't seem to have the property "ID" accessible from with the describe function.. Jan 5, 2016 at 14:51
  • I'm working with a 10.3.1 advanced version. Jan 5, 2016 at 14:53
  • 2
    It's not about a particular layer or feature class, but something general. To turn on the ids check the option ("Allow assignment [...]") in the data frame's general tab. Jul 2, 2016 at 8:47

2 Answers 2


In ArcGIS Pro you can do this:

cim_version = 'V2'
aprx = arcpy.mp.ArcGISProject(aprx_file)
map0 = aprx.listMaps()[0]
lyr0 = map0.listLayers()[0]
def0 = lyr0.getDefinition(cim_version)
# serviceLayerID will be -1 if "allow assign. unique ids to layers"
# was not check on the Data Frame properties
# in that case, serviceLayerID are in order from 0 -> len(layers) - 1
# & includes GroupLayers (can check lyr0.isGroupLayer, etc)
serviceLayerID = def0.serviceLayerID

After testing this in ArcGIS 10.3, and according to the documentation available for Layer and Describe in arcpy, and also this thread: https://geonet.esri.com/thread/178341, this functionality does not yet exist. You cannot access the layer ID from arcpy. You may be able to access it through ArcObjects if you have the knowledge.

As a workaround, can you enter the ID into the Credits or Description fields? You can access both of these fields through arcpy.

  • Goodmorning Jbalk, as you said I've written the Id layer in a table's field by using the Field Calculator tool (manually checking each layers' value). Thanks a lot for the advice, ArcObjects are my next stop.. Sep 22, 2016 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.