<?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: Trouble using &amp;quot;in_memory&amp;quot; to temporarily store geomety in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649834#M50587</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK - it's finally working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I added the clearInMemory function as suggested by jamesfreddyc and then put everything into the add-in and began debugging thatway. arcpy.env.overwriteOutput = True works correctly when using the add-in, not with copy-and-pasting into the Python window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks all for your help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Apr 2014 13:51:40 GMT</pubDate>
    <dc:creator>JamesMcBroom1</dc:creator>
    <dc:date>2014-04-15T13:51:40Z</dc:date>
    <item>
      <title>Trouble using &amp;amp;quot;in_memory&amp;amp;quot; to temporarily store geomety</title>
      <link>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649824#M50577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's my script that I'm writing before I convert it into an Add-in button. It seems like it's actually creating a feature class called "in_memory" in my default.gdb...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;layers = get_layers() bigArea = 0 bigAreaPIN = None with arcpy.da.SearchCursor(layers['parcels_fc'], ["Shape_Area", "PIN10"]) as rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row[0] &amp;gt; bigArea: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bigArea = row[0] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bigAreaPIN = row[1] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else: pass&amp;nbsp; del rows&amp;nbsp; print bigArea, bigAreaPIN&amp;nbsp; arcpy.Dissolve_management(layers['parcels_fc'], "in_memory")&amp;nbsp; with arcpy.da.SearchCursor("in_memory", ["SHAPE@"]) as rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newPolygon = row[0] del rows&amp;nbsp; subparcels = []&amp;nbsp; with arcpy.da.UpdateCursor(layers['parcels_fc'], ["PIN10", "SHAPE@"]) as rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row[0] == bigAreaPIN: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = newPolygon &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; subparcels.append(row[0]) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.deleteRow() del rows&amp;nbsp; with arcpy.da.InsertCursor(layers['superparcel'], ["original", "superparcel"]) as insert: &amp;nbsp;&amp;nbsp;&amp;nbsp; for x in subparcels: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insert.insertRow((x,bigAreaPIN)) del insert&amp;nbsp; arcpy.RefreshActiveView() arcpy.Delete_management("in_memory")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any idea what I'm doing wrong here?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 14:02:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649824#M50577</guid>
      <dc:creator>JamesMcBroom1</dc:creator>
      <dc:date>2014-04-14T14:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using "in_memory" to temporarily store geomety</title>
      <link>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649825#M50578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, that is exactly what you are telling it to do. If you want to actually utilize the in_memory workspace you must include that as a path.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.Dissolve_management(layers['parcels_fc'], r"in_memory\working")
arcpy.da.SearchCursor(r"in_memory\working", ["SHAPE@"])&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:33:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649825#M50578</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-12T03:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using "in_memory" to temporarily store geomety</title>
      <link>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649826#M50579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK - I am now seeing the correct in_memory title in the TOC sources, and the script works fine. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But when I try and run it a second time, I get another error telling me that dataset in_memory/dissolved already exists, even though:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.Delete_management(r"in_memory/dissolved") returns True.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But then I try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.Exists(r"in_memory/dissolved")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and that returns True. How can this be? Is it because I am working from the Python console?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 14:20:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649826#M50579</guid>
      <dc:creator>JamesMcBroom1</dc:creator>
      <dc:date>2014-04-14T14:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using "in_memory" to temporarily store geomety</title>
      <link>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649827#M50580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use &lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;arcpy.env.overwriteOutput = True&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure why delete wouldn't remove your temp feature class unless you are mixing workspaces. in_memory is process specific, so if you run a tool from one instance, another instance would not be referencing the same in_memory workspace.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 14:37:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649827#M50580</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2014-04-14T14:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using "in_memory" to temporarily store geomety</title>
      <link>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649828#M50581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.overwriteOutput = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The process runs again, but on the 2nd time around it updates with the newPolygon geometry from the 1st time.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 15:13:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649828#M50581</guid>
      <dc:creator>JamesMcBroom1</dc:creator>
      <dc:date>2014-04-14T15:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using "in_memory" to temporarily store geomety</title>
      <link>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649829#M50582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How are you executing this code? Through an add-in? Toolbox? Something else?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 15:36:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649829#M50582</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2014-04-14T15:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using "in_memory" to temporarily store geomety</title>
      <link>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649830#M50583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I write in PyScripter and then copy-and-paste into the ArcMap python window. Once it 'works' that's when I will drop the code into an add-in that I can share with my colleagues.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 15:39:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649830#M50583</guid>
      <dc:creator>JamesMcBroom1</dc:creator>
      <dc:date>2014-04-14T15:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using "in_memory" to temporarily store geomety</title>
      <link>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649831#M50584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The correct syntax for in_memory is "in_memory\\file". When you want to clear in memory you should simply do &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.Delete_management("in_memory")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2014 12:01:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649831#M50584</guid>
      <dc:creator>benberman</dc:creator>
      <dc:date>2014-04-15T12:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using "in_memory" to temporarily store geomety</title>
      <link>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649832#M50585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Changed my code to include the double slash and I'm still getting an error about in_memory/dissolved existing when I run the script for a second time.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2014 12:55:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649832#M50585</guid>
      <dc:creator>JamesMcBroom1</dc:creator>
      <dc:date>2014-04-15T12:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using "in_memory" to temporarily store geomety</title>
      <link>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649833#M50586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Changed my code to include the double slash and I'm still getting an error about in_memory/dissolved existing when I run the script for a second time.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I didn't fully review your codebase, but when I am doing iterative intermediate data creation then I will simply use the in_memory space as temporary workspace for the iteration.&amp;nbsp; That is, once a proc/step is complete then I remove everything from the workspace.&amp;nbsp; Here's a def I add to my .py file and simply call from the loop(s) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

 def clearINMEM():
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """ clear out the IN_MEMORY workspace of any featureclasses """

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = "IN_MEMORY"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListFeatureClasses()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ### for each FeatClass in the list of fcs's, delete it.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for f in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(f)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:33:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649833#M50586</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-12T03:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using "in_memory" to temporarily store geomety</title>
      <link>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649834#M50587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK - it's finally working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I added the clearInMemory function as suggested by jamesfreddyc and then put everything into the add-in and began debugging thatway. arcpy.env.overwriteOutput = True works correctly when using the add-in, not with copy-and-pasting into the Python window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks all for your help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2014 13:51:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649834#M50587</guid>
      <dc:creator>JamesMcBroom1</dc:creator>
      <dc:date>2014-04-15T13:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using "in_memory" to temporarily store geomety</title>
      <link>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649835#M50588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;arcpy.env.overwriteOutput = True works correctly when using the add-in, not with copy-and-pasting into the Python window.&lt;BR /&gt;&lt;BR /&gt;Thanks all for your help.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Did you set the workspace prior to setting overwriteOutput property?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In any case, I just prefer to do the removal myself rather than using the overwriteOutput = True because I am certain the job is getting done.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2014 14:08:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-using-amp-amp-quot-in-memory-amp-amp-quot/m-p/649835#M50588</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-04-15T14:08:25Z</dc:date>
    </item>
  </channel>
</rss>

