<?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: Is it possible to create a new group layer with arcpy? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1068778#M42082</link>
    <description>&lt;P&gt;For ArcGIS Pro:&lt;/P&gt;&lt;P&gt;Create an empty group layer and save it, then run this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;empty_group_layer_file = arcpy.mp.LayerFile(r"H:\New Group Layer.lyrx")
active_map = arcpy.mp.ArcGISProject("current").activeMap

# In this example, I'll use a dict of {group_layer_name: [layers]} as input. Adjust according to your existing code.
group_layers = {
    "Group Layer 1": [layer_1, layer_2],
    "Group Layer 2": [layer_3, layer_4],
}

for group_name, layers in group_layers.items():
    group = active_map.addLayer(empty_group_layer_file)[0]
    group.name = group_name
    for lyr in layers:
        active_map.addLayerToGroup(group, lyr)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Jun 2021 07:33:32 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2021-06-17T07:33:32Z</dc:date>
    <item>
      <title>Is it possible to create a new group layer with arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1068607#M42068</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to add group layers to a map with ArcPy. I have seen old answers saying this is not possible, and suggesting instead to create a layer file with the groups already created. This will not work for me because the number of groups is not known in advance.&lt;/P&gt;&lt;P&gt;Is it possible to add group layers to a map in ArcPy?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 20:31:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1068607#M42068</guid>
      <dc:creator>JesseTemplin2</dc:creator>
      <dc:date>2021-06-15T20:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create a new group layer with arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1068778#M42082</link>
      <description>&lt;P&gt;For ArcGIS Pro:&lt;/P&gt;&lt;P&gt;Create an empty group layer and save it, then run this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;empty_group_layer_file = arcpy.mp.LayerFile(r"H:\New Group Layer.lyrx")
active_map = arcpy.mp.ArcGISProject("current").activeMap

# In this example, I'll use a dict of {group_layer_name: [layers]} as input. Adjust according to your existing code.
group_layers = {
    "Group Layer 1": [layer_1, layer_2],
    "Group Layer 2": [layer_3, layer_4],
}

for group_name, layers in group_layers.items():
    group = active_map.addLayer(empty_group_layer_file)[0]
    group.name = group_name
    for lyr in layers:
        active_map.addLayerToGroup(group, lyr)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 07:33:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1068778#M42082</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-06-17T07:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create a new group layer with arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1068936#M42106</link>
      <description>&lt;P&gt;Thanks Johannes! After fixing a couple typos (AddLayer -&amp;gt; addLayer) I was able to use this to create new group layers.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 15:27:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1068936#M42106</guid>
      <dc:creator>JesseTemplin2</dc:creator>
      <dc:date>2021-06-16T15:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create a new group layer with arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1347989#M75046</link>
      <description>&lt;P&gt;this works in ArcMap too if you do the same but with an empty group .lyr file and make the appropriate changes to work in arcpy.mapping instead of arcpy.mp&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 21:31:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1347989#M75046</guid>
      <dc:creator>mTylerH</dc:creator>
      <dc:date>2023-11-09T21:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create a new group layer with arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1491146#M84507</link>
      <description>&lt;P&gt;After I got past the mental block of using &lt;STRONG&gt;Pro to create an empty LYRX file&lt;/STRONG&gt;, this works. I was expecting line one to create the file for me. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 23:56:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1491146#M84507</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2024-06-12T23:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create a new group layer with arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1654689#M99361</link>
      <description>&lt;P&gt;This is much simpler for recent versions of ArcGIS Pro (as it always should have been).&amp;nbsp; You can now create a new empty group layer with a single arcpy line like this:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;new_group_layer = mp.createGroupLayer(&lt;SPAN&gt;"New Group Layer"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;For more details, see the 'Map' class documentation at: &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/map-class.htm" target="_blank"&gt;Map—ArcGIS Pro | Documentation&lt;/A&gt;&lt;BR /&gt;(search on the page for 'creategrouplayer')&lt;/P&gt;</description>
      <pubDate>Wed, 01 Oct 2025 22:51:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1654689#M99361</guid>
      <dc:creator>GISDataTasPorts</dc:creator>
      <dc:date>2025-10-01T22:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to create a new group layer with arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1654893#M99373</link>
      <description>&lt;P&gt;lovely&lt;/P&gt;</description>
      <pubDate>Thu, 02 Oct 2025 17:02:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/is-it-possible-to-create-a-new-group-layer-with/m-p/1654893#M99373</guid>
      <dc:creator>mTylerH</dc:creator>
      <dc:date>2025-10-02T17:02:22Z</dc:date>
    </item>
  </channel>
</rss>

