<?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: Strange behavior of arcpy.Contour_3d in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/strange-behavior-of-arcpy-contour-3d/m-p/485802#M37894</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The scripting example shows the arcpy.env.workspace being set to a file gdb not to 'memory'.&amp;nbsp; the warning about memory&amp;nbsp;is worth noting&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;Use of memory-based workspaces in a Python is only valid for geoprocessing tools. Memory is not a general-purpose virtual directory where you can write files or other data.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Temporary or other outputs are set to memory (eg r"\memory\something")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/modelbuilder/the-in-memory-workspace.htm" title="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/modelbuilder/the-in-memory-workspace.htm"&gt;Write geoprocessing output to memory—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Contour_3d supports a load of environment variables, I would examine those relating to current workspace and scratch workspace&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/tool-reference/3d-analyst/contour.htm" title="https://pro.arcgis.com/en/pro-app/tool-reference/3d-analyst/contour.htm"&gt;Contour—Help | Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try the process again setting the env.workspace to point to your project gdb, and setting the results of contour to memory, then copy to the gdb or if a shapefile is needed, a folder.&lt;/P&gt;&lt;P&gt;The rest of what you noted may be real or a cascading result of what you did&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Apr 2020 06:40:26 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2020-04-03T06:40:26Z</dc:date>
    <item>
      <title>Strange behavior of arcpy.Contour_3d</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-arcpy-contour-3d/m-p/485801#M37893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have a script for ArcGIS Pro (2.4.3) which essentially does this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;1. arcpy.env.workspace = "in_memory"
2. arcpy.CopyFeatures_management("fc", "copy")
3. Stuff with copy
4. arcpy.Contour_3d("dem", "contour_lines", 10)
5. More Stuff with copy&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While the stuff in before &lt;EM&gt;Contour_3d&lt;/EM&gt; works fine, the code after throws an exception, that "copy" doesn't exist.&lt;/P&gt;&lt;P&gt;After some testing, it seems, that &lt;EM&gt;contour_3d&lt;/EM&gt; makes arcpy somehow 'forget' where to look for fc. I used Describe to find out, what was going on, and couldn't find any of the fc that where used and created during run anymore, including the just created "contour_lines".&lt;/P&gt;&lt;P&gt;What I noticed was, that doing anything not fc-related with the workspace fixed the issue.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.AddMessage(arcpy.env.workspace)
arcpy.AddMessage(arcpy.ListFeatureClasses())
arcpy.env.workspace = "in_memory"&lt;/PRE&gt;&lt;P&gt;All of those made the rest of the script work like a charm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another interesting Issue I noticed while searching for the error, is the interaction between &lt;EM&gt;Contour_3d&lt;/EM&gt; and the new &lt;EM&gt;memory&lt;/EM&gt;-workspace.&lt;/P&gt;&lt;P&gt;The reason I used the old &lt;EM&gt;in_memory&lt;/EM&gt;-workspace was, that I created the dem with&amp;nbsp;&lt;EM&gt;arcpy.MakeImageServerLayer_management()&lt;/EM&gt; (which doesn't work with the new &lt;EM&gt;memory&lt;/EM&gt;-workspace).&lt;/P&gt;&lt;P&gt;So, thinking the problem might lie within &lt;EM&gt;in_memory&lt;/EM&gt;, I replaced&amp;nbsp;&lt;EM&gt;in_memory&lt;/EM&gt; with&amp;nbsp;&lt;EM&gt;memory&lt;/EM&gt; and used some pre-created dem instead.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, strangly enough, the first error I got was:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ERROR 000880: Output feature class: 's extension is empty for the output feature class.&lt;/PRE&gt;&lt;P&gt;And I had to fix ".shp" to the name of the fc ("contour_lines.shp"), which surprised me, since I can't usually create fc with Extension in the&amp;nbsp;&lt;EM&gt;memory&lt;/EM&gt;-workspace.&lt;/P&gt;&lt;P&gt;Just to be sure I tried some other functions, all of which threw the expected Error:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ERROR 000354: The name contains invalid characters&lt;/PRE&gt;&lt;P&gt;Next strange thing is, running the tool a second time got me this Error:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ERROR 000287: Fail to create output feature class.&lt;/PRE&gt;&lt;P&gt;Apparently Contour_3d can't overwrite it's output. (why does the memory result even persist between script runs?)&lt;/P&gt;&lt;P&gt;Oh. and the first Problem wasn't fixed by changing to the new version neither.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what is going on with Contour_3d, it seems like some serious Bugs to me, or am I doing something completly wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:24:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-arcpy-contour-3d/m-p/485801#M37893</guid>
      <dc:creator>MattWeber2</dc:creator>
      <dc:date>2021-12-11T21:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior of arcpy.Contour_3d</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-arcpy-contour-3d/m-p/485802#M37894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The scripting example shows the arcpy.env.workspace being set to a file gdb not to 'memory'.&amp;nbsp; the warning about memory&amp;nbsp;is worth noting&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;Use of memory-based workspaces in a Python is only valid for geoprocessing tools. Memory is not a general-purpose virtual directory where you can write files or other data.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Temporary or other outputs are set to memory (eg r"\memory\something")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/modelbuilder/the-in-memory-workspace.htm" title="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/modelbuilder/the-in-memory-workspace.htm"&gt;Write geoprocessing output to memory—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Contour_3d supports a load of environment variables, I would examine those relating to current workspace and scratch workspace&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/tool-reference/3d-analyst/contour.htm" title="https://pro.arcgis.com/en/pro-app/tool-reference/3d-analyst/contour.htm"&gt;Contour—Help | Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try the process again setting the env.workspace to point to your project gdb, and setting the results of contour to memory, then copy to the gdb or if a shapefile is needed, a folder.&lt;/P&gt;&lt;P&gt;The rest of what you noted may be real or a cascading result of what you did&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2020 06:40:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-arcpy-contour-3d/m-p/485802#M37894</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2020-04-03T06:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior of arcpy.Contour_3d</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-arcpy-contour-3d/m-p/485803#M37895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I Always understood the Paragraph with you cited as refering to using memory workspaces for everyday work.&lt;/P&gt;&lt;P&gt;So if I have a script like:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;1. arcpy.Clip_analysis("to_clip_1", "clipping", "tmp_1")
2. arcpy.lCip_analysis("to_clip_2", "clipping", "tmp_2")
3. arcpy.Dissolve_management("tmp_1", "tmp_2", "Output_to_folder")&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; word-wrap: break-word;"&gt;where the tmp-results are supposed to be in the memory workspace, and the output in some folder or gdb, do I need to specify it like this?&lt;/SPAN&gt;
   1. arcpy.env.workspace = path_for_output
   2. arcpy.Clip_analysis("to_clip_1", "clipping", r"memory\tmp_1")
   3. arcpy.Clip_analysis("to_clip_2", "clipping", r"memory\tmp_2")
   4. arcpy.Dissolve_management("tmp_1", "tmp_2", "Output_to_folder")&lt;/PRE&gt;&lt;P&gt;If arcpy.env.workspace = "memory" sets the Workspace to some file gdb, where is this file gdb located? When I describe a fc and print the catalogPath, the output is just "memory\fc".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try your suggestion for the specific script, once I am sure that I got it right and will report on the results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:24:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-arcpy-contour-3d/m-p/485803#M37895</guid>
      <dc:creator>MattWeber2</dc:creator>
      <dc:date>2021-12-11T21:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior of arcpy.Contour_3d</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-arcpy-contour-3d/m-p/485804#M37896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The final result that you want to use/save is to your file gdb probably the project one, or create a locally save gdb solely for that process&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2020 10:45:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-arcpy-contour-3d/m-p/485804#M37896</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2020-04-03T10:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior of arcpy.Contour_3d</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-arcpy-contour-3d/m-p/485805#M37897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, but somehow your anwser makes me wonder if I asked my question the right way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. My tool shows unexpected behavior when I use what I believed to be the memory-workspace&amp;nbsp;&lt;/P&gt;&lt;P&gt;(arcpy.env.workspace = "in_memory"/"memory")&lt;/P&gt;&lt;P&gt;2. You say that I am not using the memory-workspace, but rather a file gdb and the issues might be related to either that or some environment variables.&lt;/P&gt;&lt;P&gt;3. I ask (intended to) ask about the proper way to save to memory-workspace&lt;/P&gt;&lt;P&gt;4. You explain how to save the final result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, apparently I made a mistake with one of the questions, sorry for that.&lt;/P&gt;&lt;P&gt;To rephrase the issue. I have a Toolbox, that does a lot of stuff like clipping, dissolving, union, create contours, calc geometries, etc. etc. The Toolbox is primarily used to enable non-GIS experts to calculate complex results and ensure comparibility of the results.&lt;/P&gt;&lt;P&gt;95% of the results created during runtime are just intermediat steps and not needed, meaning I'd like to have them in a temporary Location. Since they are created by standard ArcGIS GP-tools like Clip or Union, I thought the memory-workspace would be the ideal solution. (Quoting from the offical documentation paqe:&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #4c4c4c; font-family: 'Avenir Next W01','Avenir Next W00','Avenir Next','Avenir','Helvetica Neue',sans-serif; font-size: 17px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;so it is an ideal location to write intermediate data created in a &lt;/SPAN&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/modelbuilder/what-is-modelbuilder-.htm" style="background-color: transparent; color: #0074b8; font-family: &amp;amp;quot; avenir next w01&amp;amp;quot;,&amp;amp;quot;avenir next w00&amp;amp;quot;,&amp;amp;quot;avenir next&amp;amp;quot;,&amp;amp;quot;avenir&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,sans-serif; font-size: 17px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;ModelBuilder model&lt;/A&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #4c4c4c; font-family: 'Avenir Next W01','Avenir Next W00','Avenir Next','Avenir','Helvetica Neue',sans-serif; font-size: 17px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt; or &lt;/SPAN&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/basics/python-and-geoprocessing.htm" style="background-color: transparent; color: #0074b8; font-family: &amp;amp;quot; avenir next w01&amp;amp;quot;,&amp;amp;quot;avenir next w00&amp;amp;quot;,&amp;amp;quot;avenir next&amp;amp;quot;,&amp;amp;quot;avenir&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,sans-serif; font-size: 17px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;Python script&lt;/A&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #4c4c4c; font-family: 'Avenir Next W01','Avenir Next W00','Avenir Next','Avenir','Helvetica Neue',sans-serif; font-size: 17px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Now, it seems like I misunderstood something essential about how to use the memory-workspace (or I misunderstood your first anwser), so let me ask again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to set the env.workspace to a memory-workspace?&lt;/P&gt;&lt;P&gt;Do I need to set the location for each output that I want to be temporary manually to the memory-workspace? (i.e. r"memory\tmp_out")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the long text, with the somehow unrelated seeming questions, but without a clear understanding about how to save temporary results, I don't think I can try your proposed solutions for the actual question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2020 12:24:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-arcpy-contour-3d/m-p/485805#M37897</guid>
      <dc:creator>MattWeber2</dc:creator>
      <dc:date>2020-04-03T12:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior of arcpy.Contour_3d</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-arcpy-contour-3d/m-p/485806#M37898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;set each one as r"\memory\whatever" ... at least that is what I have used without issue... maybe others have had success with&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = .... but your case suggests that you shouldn't&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2020 13:54:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-arcpy-contour-3d/m-p/485806#M37898</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2020-04-03T13:54:54Z</dc:date>
    </item>
  </channel>
</rss>

