<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Listing layers in a group in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736547#M57013</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! I'm not in the office today, so I can't test it, but I will as soon as I get back. The ApplySymbologyFromLayer_management tool, however, doesn't work for me because it only applies symbology if there is a polygon within the feature class present; however I'm trying to apply all symbology for when I need to add polygons, so I'm using the UpdateLayer function. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I should also mention that I'm brand new to Python and any programming language, so some of this stuff is a bit over my head.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Jun 2016 17:36:05 GMT</pubDate>
    <dc:creator>AndrewGehlot</dc:creator>
    <dc:date>2016-06-22T17:36:05Z</dc:date>
    <item>
      <title>Listing layers in a group</title>
      <link>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736543#M57009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to use arcpy to list all of the layers in a group to apply symbology to all of them at once. When I use the arcpy.mapping.ListLayers(mxd, "Group Layer", df), it only returns the name of the group layer and not the layers within the group, so I am unable to iterate through them. I've tried several different queries, but all I seem to get it to do is list every single layer in the document (not what I want) or just the group layer name (also not what I want).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know how to specify it to list all of the layers in the group? The ArcGIS help tells me it should be able to do that, listing first the name of the group layer followed by each layer within the group, but it is not working for me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2016 03:27:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736543#M57009</guid>
      <dc:creator>AndrewGehlot</dc:creator>
      <dc:date>2016-06-22T03:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Listing layers in a group</title>
      <link>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736544#M57010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you ever throw in the print statements to see what was being returned at each step?&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/178821"&gt;Updating group layer symbology in arcpy&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start with little things, like moving the data frame to the top of the table of contents and drop the wildcard or temporarily remove anything other than the group layer from there as well to see what is returned.&amp;nbsp; Once you get a basic case documented, then you can add other layers back in, and then try your wildcards and indexing &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2016 08:02:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736544#M57010</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-22T08:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Listing layers in a group</title>
      <link>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736545#M57011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this function:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def listGroupLayer(glayername):
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument('CURRENT')
&amp;nbsp;&amp;nbsp;&amp;nbsp; df = mxd.activeDataFrame
&amp;nbsp;&amp;nbsp;&amp;nbsp; layers = arcpy.mapping.ListLayers(df)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for l in layers:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if l.isGroupLayer and l.name == glayername:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Layers in " + glayername + ":"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; glayers = arcpy.mapping.ListLayers(l)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for gl in glayers:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print gl.name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # apply symbology
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ApplySymbologyFromLayer_management(gl,r"C:\GIS\lyrfiles\mylayersymbology.lyr")

# use as 
listGroupLayer("MyGroupLayer")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:23:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736545#M57011</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2021-12-12T07:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Listing layers in a group</title>
      <link>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736546#M57012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Andrew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a snippet from some python that I use to export all of the layer files from an MXD.&amp;nbsp; I'm sure you can modify for your own purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for df in arcpy.mapping.ListDataFrames(mxd, ""):&lt;/P&gt;&lt;P&gt;&amp;nbsp; for lyr in arcpy.mapping.ListLayers(mxd, "", df):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.isFeatureLayer or lyr.isRasterLayer or lyr.isGroupLayer:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Layer: " + lyr.name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.saveACopy(lyr_dir+lyr.name+".lyr")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print lyr.name + " had a little issue"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2016 14:34:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736546#M57012</guid>
      <dc:creator>andrewj_ca</dc:creator>
      <dc:date>2016-06-22T14:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Listing layers in a group</title>
      <link>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736547#M57013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! I'm not in the office today, so I can't test it, but I will as soon as I get back. The ApplySymbologyFromLayer_management tool, however, doesn't work for me because it only applies symbology if there is a polygon within the feature class present; however I'm trying to apply all symbology for when I need to add polygons, so I'm using the UpdateLayer function. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I should also mention that I'm brand new to Python and any programming language, so some of this stuff is a bit over my head.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2016 17:36:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736547#M57013</guid>
      <dc:creator>AndrewGehlot</dc:creator>
      <dc:date>2016-06-22T17:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Listing layers in a group</title>
      <link>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736548#M57014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! I'll play with it when I'm back in the office.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2016 17:36:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736548#M57014</guid>
      <dc:creator>AndrewGehlot</dc:creator>
      <dc:date>2016-06-22T17:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Listing layers in a group</title>
      <link>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736549#M57015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I did. What I was getting returned was just the name of the group layer, and not the layers within it. I was able to make a workaround by using a wildcard because all of my layers began with the same phrase, but I won't be able to make that solution more general, as I'm working with far more data tiles that have different names.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jun 2016 14:21:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736549#M57015</guid>
      <dc:creator>AndrewGehlot</dc:creator>
      <dc:date>2016-06-27T14:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Listing layers in a group</title>
      <link>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736550#M57016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've been trying to get something similar working with Arcpro. I've tried the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;p = arcpy.mp.ArcGISProject("CURRENT")&lt;/P&gt;&lt;P&gt;m = p.listMaps()[0]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for lyr in m.listLayers():&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.isGroupLayer:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; glayers = m.listLayers(lyr)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for gl in glayers:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(gl.name)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I only have one group layer for testing (the group layer has 5 layers in it) and there are 2 non-group layers.&lt;/P&gt;&lt;P&gt;The output is just printing the name of the initial group layer rather than those layers within the group. I suspect it's due to the changes in arcpy from arcMap to arcPro, specifically between ListLayers and listLayers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Feb 2018 14:19:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736550#M57016</guid>
      <dc:creator>Oliver_Burdekin</dc:creator>
      <dc:date>2018-02-26T14:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Listing layers in a group</title>
      <link>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736551#M57017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think your second listLayers is implemented incorrectly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works for me in ArcPro:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;proj &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ArcGISProject&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'CURRENT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
m &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; proj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listMaps&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
ml &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; m&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; l &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; ml&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; l&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;isGroupLayer&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;l&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyrs &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; l&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; lyr &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; lyrs&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:23:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736551#M57017</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2021-12-12T07:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Listing layers in a group</title>
      <link>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736552#M57018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks you're right! Got it running now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Feb 2018 11:23:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/736552#M57018</guid>
      <dc:creator>Oliver_Burdekin</dc:creator>
      <dc:date>2018-02-27T11:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Listing layers in a group</title>
      <link>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/1169191#M64431</link>
      <description>&lt;P&gt;thanks, this works for me in arcpro too&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 08:34:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/1169191#M64431</guid>
      <dc:creator>SutanMufti</dc:creator>
      <dc:date>2022-04-29T08:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Listing layers in a group</title>
      <link>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/1245911#M66427</link>
      <description>&lt;P&gt;Thank you! Got it running in 3.0 using Notebook---&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 01:20:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-layers-in-a-group/m-p/1245911#M66427</guid>
      <dc:creator>CatherineHall678</dc:creator>
      <dc:date>2023-01-06T01:20:06Z</dc:date>
    </item>
  </channel>
</rss>

