<?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: How do I add a layer in the 'memory' workspace to the current active map in ArcGIS Pro using Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1245125#M66388</link>
    <description>&lt;P&gt;@Anonymous User&amp;nbsp;Thanks for this! I ran into this same issue in a larger geoprocessing tool where I wanted to display rapid, ephemeral results and the IO expense really hurt user experience.&amp;nbsp; Based on your solution I threw together a helper function that I reference in a bunch of scripts now:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def memory_to_active_map(self, memory_fc):
    active_map = arcpy.mp.ArcGISProject("CURRENT").activeMap
    lyr_result = arcpy.MakeFeatureLayer_management(
        memory_fc, arcpy.Describe(memory_fc).name)
    mem_lyr = lyr_result.getOutput(0)
    return active_map.addLayer(mem_lyr)[0]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Jan 2023 21:36:40 GMT</pubDate>
    <dc:creator>EricEagle</dc:creator>
    <dc:date>2023-01-03T21:36:40Z</dc:date>
    <item>
      <title>How do I add a layer in the 'memory' workspace to the current active map in ArcGIS Pro using Python</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1085342#M61934</link>
      <description>&lt;P&gt;According to the ArcGIS Pro support pages, "&lt;SPAN&gt;You can add&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="usertext"&gt;memory&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;datasets to a map in&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="ph"&gt;ArcGIS Pro&lt;/SPAN&gt;&lt;SPAN&gt;.".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have a layer in the 'memory' workspace that I would like to add to my current active map.&amp;nbsp; I've tried:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;mem_lyr = r"memory\Test_Layer"
aprx = arcpy.mp.ArcGISProject("CURRENT")
aprx_map = aprx.activeMap
aprx_map.addDataFromPath(mem_lyr)&lt;/LI-CODE&gt;&lt;P&gt;but get the below error. Is there a correct way to add layers in memory to the current map?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Traceback (most recent call last):
  File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 1862, in addDataFromPath
    return convertArcObjectToPythonObject(self._arc_object.addDataFromPath(*gp_fixargs((data_path,), True)))
RuntimeError&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Aug 2021 14:53:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1085342#M61934</guid>
      <dc:creator>MattHowe</dc:creator>
      <dc:date>2021-08-03T14:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a layer in the 'memory' workspace to the current active map in ArcGIS Pro using Python</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1085373#M61936</link>
      <description>&lt;P&gt;Most ArcPy functions and GP tools understand the "memory" and "in_memory" aliases, but not all of them.&amp;nbsp; The addDataFromPath method of the ArcPy Map object does not understand or honor it.&lt;/P&gt;&lt;P&gt;I suggest changing your workflow to start with &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/make-feature-layer.htm" target="_blank"&gt;Make Feature Layer (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt; and then use addLayer method of &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;STRONG&gt;.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Aug 2021 15:46:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1085373#M61936</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-08-03T15:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a layer in the 'memory' workspace to the current active map in ArcGIS Pro using Python</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1085485#M61937</link>
      <description>&lt;P&gt;Thanks Joshua. Unfortunately I get the same error. I'll contact Esri support.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Aug 2021 20:17:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1085485#M61937</guid>
      <dc:creator>MattHowe</dc:creator>
      <dc:date>2021-08-03T20:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a layer in the 'memory' workspace to the current active map in ArcGIS Pro using Python</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1085556#M61938</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/485616"&gt;@MattHowe&lt;/a&gt;&amp;nbsp;; can you tell us what version of arcgis pro you are using?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Aug 2021 23:25:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1085556#M61938</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-08-03T23:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a layer in the 'memory' workspace to the current active map in ArcGIS Pro using Python</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1085592#M61940</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3374"&gt;@JoeBorgione&lt;/a&gt;&amp;nbsp; sure, I'm using 2.7.2&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 06:37:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1085592#M61940</guid>
      <dc:creator>MattHowe</dc:creator>
      <dc:date>2021-08-04T06:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a layer in the 'memory' workspace to the current active map in ArcGIS Pro using Python</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1183586#M64777</link>
      <description>&lt;P&gt;Still does not work in 2.9.3 - Copy Features works but not Make Feature Layer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code runs fine in 2.4.2.&lt;/P&gt;&lt;P&gt;Code runs fine in 2.9.3 when ran in the interactive widow.&amp;nbsp; If fails when run in a Toolbox.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Tempcopy = arcpy.CopyFeatures_management(ParOrionLayer, "memory/tempParReg")

arcpy.MakeFeatureLayer_management(Tempcopy, "memory/tempO")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Traceback (most recent call last):
  File "&amp;lt;string&amp;gt;", line 91, in execute
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 1287, in Describe
    return gp.describe(value, data_type)
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 384, in describe
    self._gp.Describe(*gp_fixargs(args, True)))
OSError: "memory/tempO" does not exist

Failed to execute (PDFTool).&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With addLayer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;ParOTempcopy = arcpy.CopyFeatures_management(ParOrionLayer, "memory/tempParReg")
ParOrion = arcpy.MakeFeatureLayer_management(ParOTempcopy, "memory/tempOrion")
m.addLayer(ParOrion, "TOP")&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;  File "&amp;lt;string&amp;gt;", line 85, in execute
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py", line 191, in fn_
    return fn(*args, **kw)
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 1843, in addLayer
    return convertArcObjectToPythonObject(self._arc_object.addLayer(*gp_fixargs((add_layer_or_layerfile, add_position), True)))
ValueError: memory/tempOrion&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 16:41:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1183586#M64777</guid>
      <dc:creator>MatthewDriscoll</dc:creator>
      <dc:date>2022-06-16T16:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a layer in the 'memory' workspace to the current active map in ArcGIS Pro using Python</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1240447#M66249</link>
      <description>&lt;P&gt;Still seems to be a problem in ArcGIS Pro 3.0.2.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 01:15:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1240447#M66249</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-12-13T01:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a layer in the 'memory' workspace to the current active map in ArcGIS Pro using Python</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1240809#M66258</link>
      <description>&lt;P&gt;I think I found the solution, at least for 3.0.2.&lt;/P&gt;&lt;P&gt;You have to make a feature layer, and then use the .getOutput() method on the results object to get the actual layer object.&amp;nbsp;&lt;EM&gt;That&amp;nbsp;&lt;/EM&gt;can be added to a map. You still need to run the script from a toolbox inside of the map, since it's in memory, a standalone python script will add the layer to the map, but the connection to the data source will be broken.&lt;BR /&gt;&lt;BR /&gt;If you look at the datatypes in the second screenshot you can see why it works.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fix1.PNG" style="width: 711px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/58428i70F947A50B54174A/image-dimensions/711x217?v=v2" width="711" height="217" role="button" title="fix1.PNG" alt="fix1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fix2.PNG" style="width: 423px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/58429iC439099C30803983/image-dimensions/423x204?v=v2" width="423" height="204" role="button" title="fix2.PNG" alt="fix2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 21:27:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1240809#M66258</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-12-13T21:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a layer in the 'memory' workspace to the current active map in ArcGIS Pro using Python</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1240974#M66266</link>
      <description>&lt;P&gt;Interesting, thanks&amp;nbsp;@Anonymous User. I'll give that a shot.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2022 08:01:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1240974#M66266</guid>
      <dc:creator>MattHowe</dc:creator>
      <dc:date>2022-12-14T08:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a layer in the 'memory' workspace to the current active map in ArcGIS Pro using Python</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1240982#M66267</link>
      <description>&lt;P&gt;@Anonymous User&amp;nbsp;I can confirm this works. Thanks a lot and happy holidays when you get there!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2022 08:38:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1240982#M66267</guid>
      <dc:creator>MattHowe</dc:creator>
      <dc:date>2022-12-14T08:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a layer in the 'memory' workspace to the current active map in ArcGIS Pro using Python</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1245125#M66388</link>
      <description>&lt;P&gt;@Anonymous User&amp;nbsp;Thanks for this! I ran into this same issue in a larger geoprocessing tool where I wanted to display rapid, ephemeral results and the IO expense really hurt user experience.&amp;nbsp; Based on your solution I threw together a helper function that I reference in a bunch of scripts now:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def memory_to_active_map(self, memory_fc):
    active_map = arcpy.mp.ArcGISProject("CURRENT").activeMap
    lyr_result = arcpy.MakeFeatureLayer_management(
        memory_fc, arcpy.Describe(memory_fc).name)
    mem_lyr = lyr_result.getOutput(0)
    return active_map.addLayer(mem_lyr)[0]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 21:36:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-add-a-layer-in-the-memory-workspace-to/m-p/1245125#M66388</guid>
      <dc:creator>EricEagle</dc:creator>
      <dc:date>2023-01-03T21:36:40Z</dc:date>
    </item>
  </channel>
</rss>

