Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone now how to add a group layer with Python in ArcGIS Desktop 10?

I can use arcpy.mapping.AddLayer but surely this is only for an actual layer as opposed to a group layer.

so far I have this

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.listdataframes(mxd, "layers")[0]
share|improve this question

I do not think ArcPy provides anything to create group layer directly, but there is a simple workaround. You can create a .lyr file which contains a single empty group layer and add it to your map:

groupLayer = arcpy.mapping.Layer(r"EmptyGroupLayer.lyr")
arcpy.mapping.AddLayer(dataFrame, groupLayer, "BOTTOM")

Then you can use the AddLayerToGroup function to add another layers under your group layer.

share|improve this answer
I have a couple of layer groups but within them further groups. Let's call them parent and child. the parents are all unique however the children within each parent are the same. EG Incidentals>Birds and Transects>Bird. Is there anyway to avoid the conflict of the two bird group layers having the same name? – Oliver Burdekin Nov 26 '12 at 18:57
This gave me an error when I called AddLayerToGroup. I found a solution here: groupLayer = arcpy.mapping.ListLayers(mxd, "AAAA", dataFrame)[0] – Gabriel Littman May 24 at 2:28

Save an empty group layer as a .lyr file. Then you can use AddLayer to add it to your map and then add new layers from there.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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