Can you combine multiple layers in a .lyrx through python?

597
4
07-06-2018 11:35 AM
CyrusBlankinship1
New Contributor III

I know this is possible through the Pro UX, but i'm trying to write it in python. From what I see in the geoprocessing help, the tool only accepts one input

0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Cyrus,

I believe you will need to create a Group Layer ahead of time. You can add the layers to the Group, then create the layer file from the Group.  However, from what I could find there is no way to create a Group Layer via python.

JoeBorgione
MVP Emeritus

Interesting that you can add a layer to a group but not create one.... AddLayerToGroup—Help | ArcGIS Desktop 

That should just about do it....
CyrusBlankinship1
New Contributor III

Ya, unfortunately that doesn't help. I need to sort through a list of ~1000 buildings, create a group for each combining 5 layers, and export the group to a .lyrx.

Odd that the functionality is included through manually selecting the layers-->right clicking-->share as layer file but NOT through arcpy. 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

You can just create one empty group layer file and use it as a template, i.e., add 5 layers to the empty group layer and save it, rinse, repeat.