<?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: Pulling Feature Layer from Group Layer and apply Symbology? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/pulling-feature-layer-from-group-layer-and-apply/m-p/588252#M46105</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Richard. That helps for sure. I updated my post while you were responding with an additional question&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;More specifically, I don't suppose there is a directory path for feature layers inside of a group layer (i.e. G:\layers\Test_Grid_Group.lyr\Unit) &amp;lt;---That doesn't work, but I'm looking for something like that.... &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Reason being is, I am setting up a spreadsheet that include a column for dataSources and one for its associated layer file. Each layer file is set up quite dynamically (some make use of group layers, otehrs are standalone feature layers) and there are a couple hundred of them. Instead of scripting to iterate over each individual layer file to test and find unique feature layers, It would make more sense to have a full path directory in my spreadhseet (configuration file) and read from there. I don't think there is a file path structure to a feature layer within a group layer, but I thought I'd ask.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 May 2014 16:35:51 GMT</pubDate>
    <dc:creator>MikeMacRae</dc:creator>
    <dc:date>2014-05-15T16:35:51Z</dc:date>
    <item>
      <title>Pulling Feature Layer from Group Layer and apply Symbology?</title>
      <link>https://community.esri.com/t5/python-questions/pulling-feature-layer-from-group-layer-and-apply/m-p/588250#M46103</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to use the symbology from a layer file, to apply to a layer in my map via python. My layer file is a group layer file. The layer in the map is not a grouped layer file. When I do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for lyr in arcpy.mapping.ListLayers(mxd,"",df):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Layer = arcpy.mapping.Layer(path_to_LayerFile)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ApplySymbologyFromLayer_management (lyr, Layer)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It will crash beause the 'Layer' is a group layer, where lyr is not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I flipped through the arcpy.mapping.Layer helpfile &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000008000000" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt;&lt;SPAN&gt; and I can see that I can test for isGroupLayer or isFeatureLayer, but I'm not sure how I would go about grabbing the underlying feature layer from the group layer and apply the symbology to lyr in my example about? More specifically, I don't suppose there is a directory path for feature layers inside of a group layer (i.e. G:\layers\Test_Grid_Group.lyr\Unit) &amp;lt;---That doesn't work, but I'm looking for something like that....&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:16:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pulling-feature-layer-from-group-layer-and-apply/m-p/588250#M46103</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2021-12-12T01:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling Feature Layer from Group Layer and apply Symbology?</title>
      <link>https://community.esri.com/t5/python-questions/pulling-feature-layer-from-group-layer-and-apply/m-p/588251#M46104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Since you can only apply symbology to a feature layer you want to test for isFeatureLayer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for lyr in arcpy.mapping.ListLayers(mxd,"",df):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Layer = arcpy.mapping.Layer(path_to_LayerFile)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Layer.isFeatureLayer:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ApplySymbologyFromLayer_management (lyr, Layer)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:16:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pulling-feature-layer-from-group-layer-and-apply/m-p/588251#M46104</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-12T01:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling Feature Layer from Group Layer and apply Symbology?</title>
      <link>https://community.esri.com/t5/python-questions/pulling-feature-layer-from-group-layer-and-apply/m-p/588252#M46105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Richard. That helps for sure. I updated my post while you were responding with an additional question&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;More specifically, I don't suppose there is a directory path for feature layers inside of a group layer (i.e. G:\layers\Test_Grid_Group.lyr\Unit) &amp;lt;---That doesn't work, but I'm looking for something like that.... &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Reason being is, I am setting up a spreadsheet that include a column for dataSources and one for its associated layer file. Each layer file is set up quite dynamically (some make use of group layers, otehrs are standalone feature layers) and there are a couple hundred of them. Instead of scripting to iterate over each individual layer file to test and find unique feature layers, It would make more sense to have a full path directory in my spreadhseet (configuration file) and read from there. I don't think there is a file path structure to a feature layer within a group layer, but I thought I'd ask.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 May 2014 16:35:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pulling-feature-layer-from-group-layer-and-apply/m-p/588252#M46105</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2014-05-15T16:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling Feature Layer from Group Layer and apply Symbology?</title>
      <link>https://community.esri.com/t5/python-questions/pulling-feature-layer-from-group-layer-and-apply/m-p/588253#M46106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks Richard. That helps for sure. I updated my post while you were responding with an additional question&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Reason being is, I am setting up a spreadsheet that include a column for dataSources and one for its associated layer file. Each layer files are set up quite dynamically (some make use of group layers, otehrs are standalone feature layers) and there are a couple hundred of them. Instead of scripting to iterate over each individual layer file to test, I would rather just find the path, stick it into my spreadsheet and read the path from there. I don't think there is a file path structure to a feature layer within a group layer, but I thought I'd ask.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You don't query the GroupLayer for the Feature layer paths inside of it.&amp;nbsp; You only query feature layers for the path and determine the feature layer groups by doing the opposite and querying the longName of each feature layer to find out if it is in a group layer.&amp;nbsp; The helps says:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"There are two ways of determining if a layer is a group layer. First, you can check to see if the layer supports the isGroupLayer property. Second, you can evaluate the longName property. A layer's longName value will include the group name in addition to the layer name. For example, a layer named Layer1 in a group layer named Group1 will have a longName value of Group1\Layer1. If the name value is equal to longName value, then the layer is not a group layer or the layer is not inside a group layer."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So something like this should work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for lyr in arcpy.mapping.ListLayers(mxd,"",df):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Layer = arcpy.mapping.Layer(path_to_LayerFile)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Layer.isFeatureLayer:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Layer.longName &amp;lt;&amp;gt; Layer.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; groupLayerNames = layer.longName.split(r"\")
&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; for i = 0 to len(grougLayerNames) - 1:
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; print groupLayerNames&lt;I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ApplySymbologyFromLayer_management (lyr, Layer)&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not sure if multiple group layer levels are handled in the longName property or if only the immediate parent Group layer is listed.&amp;nbsp; If all group layers containing a feature layer are included in the longName, then the for loop can get all of the group containers in order.&amp;nbsp; If only the immediate parent group layer is listed at each level then some form or recursion method would have to work its way out to the outermost group and keep track of each inner group layer level.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:16:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pulling-feature-layer-from-group-layer-and-apply/m-p/588253#M46106</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-12T01:16:17Z</dc:date>
    </item>
  </channel>
</rss>

