<?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: Using AddLayer in a python loop to add layers to a map in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/using-addlayer-in-a-python-loop-to-add-layers-to-a/m-p/1249971#M64463</link>
    <description>&lt;P&gt;did you try&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;addDataFromPath (data_path)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The paths are as follows&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aoi = "PA_SCENTRAL"
LayerPath = ("D:\\Mobile Map Package Creator\\DEPLOYMENT_DATA_PACKAGES\\" + aoi + "\\map_data.gdb\\")
LayerList = ("COMPLEXES", "MILEMARKERS", "Zones", "ROAD_NAMES")
for Layer in LayerList:
    print(LayerPath + Layer )
    
D:\Mobile Map Package Creator\DEPLOYMENT_DATA_PACKAGES\PA_SCENTRAL\map_data.gdb\COMPLEXES
D:\Mobile Map Package Creator\DEPLOYMENT_DATA_PACKAGES\PA_SCENTRAL\map_data.gdb\MILEMARKERS
D:\Mobile Map Package Creator\DEPLOYMENT_DATA_PACKAGES\PA_SCENTRAL\map_data.gdb\Zones
D:\Mobile Map Package Creator\DEPLOYMENT_DATA_PACKAGES\PA_SCENTRAL\map_data.gdb\ROAD_NAMES&lt;/LI-CODE&gt;&lt;P&gt;.&amp;nbsp; Are they all in that gdb in that path&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jan 2023 17:03:22 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2023-01-20T17:03:22Z</dc:date>
    <item>
      <title>Using AddLayer in a python loop to add layers to a map</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-addlayer-in-a-python-loop-to-add-layers-to-a/m-p/1249919#M64460</link>
      <description>&lt;P&gt;I'm running ArcGIS Pro 3.x and trying to add a list of layers to a map. My guess is I'm not getting the python correct for the path to the feature classes in a FGDB.&lt;/P&gt;&lt;P&gt;Here's my python:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("MMPK Output*")[0]

aoi = "PA_SCENTRAL"
LayerPath = ("D:\\Mobile Map Package Creator\\DEPLOYMENT_DATA_PACKAGES\\" + aoi + "\\map_data.gdb\\")

LayerList = ("COMPLEXES", "MILEMARKERS", "Zones", "ROAD_NAMES")

for Layer in LayerList:
  Layer2Add = (LayerPath + Layer )
  AddStatus = m.addLayer(Layer2Add)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here the error message I get back:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 14, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py", line 191, in fn_&lt;BR /&gt;return fn(*args, **kw)&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 2217, in addLayer&lt;BR /&gt;return convertArcObjectToPythonObject(self._arc_object.addLayer(*gp_fixargs((add_layer_or_layerfile, add_position), True)))&lt;BR /&gt;ValueError: D:\Mobile Map Package Creator\DEPLOYMENT_DATA_PACKAGES\PA_SCENTRAL\map_data.gdb\COMPLEXES&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 15:56:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-addlayer-in-a-python-loop-to-add-layers-to-a/m-p/1249919#M64460</guid>
      <dc:creator>JohnFix1</dc:creator>
      <dc:date>2023-01-20T15:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using AddLayer in a python loop to add layers to a map</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-addlayer-in-a-python-loop-to-add-layers-to-a/m-p/1249971#M64463</link>
      <description>&lt;P&gt;did you try&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;addDataFromPath (data_path)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The paths are as follows&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aoi = "PA_SCENTRAL"
LayerPath = ("D:\\Mobile Map Package Creator\\DEPLOYMENT_DATA_PACKAGES\\" + aoi + "\\map_data.gdb\\")
LayerList = ("COMPLEXES", "MILEMARKERS", "Zones", "ROAD_NAMES")
for Layer in LayerList:
    print(LayerPath + Layer )
    
D:\Mobile Map Package Creator\DEPLOYMENT_DATA_PACKAGES\PA_SCENTRAL\map_data.gdb\COMPLEXES
D:\Mobile Map Package Creator\DEPLOYMENT_DATA_PACKAGES\PA_SCENTRAL\map_data.gdb\MILEMARKERS
D:\Mobile Map Package Creator\DEPLOYMENT_DATA_PACKAGES\PA_SCENTRAL\map_data.gdb\Zones
D:\Mobile Map Package Creator\DEPLOYMENT_DATA_PACKAGES\PA_SCENTRAL\map_data.gdb\ROAD_NAMES&lt;/LI-CODE&gt;&lt;P&gt;.&amp;nbsp; Are they all in that gdb in that path&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 17:03:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-addlayer-in-a-python-loop-to-add-layers-to-a/m-p/1249971#M64463</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-01-20T17:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using AddLayer in a python loop to add layers to a map</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-addlayer-in-a-python-loop-to-add-layers-to-a/m-p/1250095#M64476</link>
      <description>&lt;P&gt;Dan, I thought I did try it without success. But I just tried it and it works! Thank you.&lt;/P&gt;&lt;P&gt;I did:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("MMPK Output*")[0]

aoi = "PA_SCENTRAL"
LayerPath = ("D:\\Mobile Map Package Creator\\DEPLOYMENT_DATA_PACKAGES\\" + aoi + "\\map_data.gdb\\")

LayerList = ("COMPLEXES", "MILEMARKERS", "Zones", "ROAD_NAMES")
for Layer in LayerList:
  AddStatus = m.addDataFromPath(LayerPath + Layer)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 20 Jan 2023 20:41:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-addlayer-in-a-python-loop-to-add-layers-to-a/m-p/1250095#M64476</guid>
      <dc:creator>JohnFix1</dc:creator>
      <dc:date>2023-01-20T20:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using AddLayer in a python loop to add layers to a map</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-addlayer-in-a-python-loop-to-add-layers-to-a/m-p/1250099#M64477</link>
      <description>&lt;P&gt;I do have a question for you. In my layers list, I also need to include a network dataset. It's in the same FGDB. The feature dataset is "My_Network" and the network dataset is "My_Network_ND".&lt;/P&gt;&lt;P&gt;I can't seem to figure out how to include this feature in my loop.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 21:01:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-addlayer-in-a-python-loop-to-add-layers-to-a/m-p/1250099#M64477</guid>
      <dc:creator>JohnFix1</dc:creator>
      <dc:date>2023-01-20T21:01:33Z</dc:date>
    </item>
  </channel>
</rss>

