3

From the ArcGIS Desktop Help:

The layer that is created by the tool is temporary and will not persist after the session ends unless the layer is saved to disk or the map document is saved.

However, it does not state where this temporary location is.

Is it the same as the "in_memory" location that Esri suggests using while geoprocessing?

marked as duplicate by PolyGeo Sep 13 '14 at 0:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • This related post may be helpful: gis.stackexchange.com/questions/72193/… – Aaron Sep 12 '14 at 21:10
  • 1
    Thanks for finding that duplicate @Aaron - I had forgotten that it had come up before – PolyGeo Sep 12 '14 at 21:32
  • 1
    A layer (unless written to a layer file or map document) is only stored in memory but it is not stored in an in_memory workspace. An in_memory workspace is also stored in memory but the two are not co-extensive. – PolyGeo Sep 12 '14 at 23:22
  • 3
    Even though I made this a duplicate I do think that it is a valuable question because it is asked in a different way that can act as a signpost to the earlier Q&A and in its own right led to some useful discussion. The value of such duplicates has been expressed by Jeff Atwood. Consequently, I have rolled back your last edit so that it can serve that purpose. – PolyGeo Sep 13 '14 at 6:01
4

The "in_memory" location is usually in your temp directory in a temporary file geodatabase. You can test this by running any tool and saving it to an "in_memory" location and then using the data sources tab in ArcMap. This data is indeed deleted after your script is complete or you close ArcMap. I am not sure where layers from MakeFeatureLayer() are stored. But below will show an example of where an in_memory feature class is stored.

enter image description here

I should Add you can find this location by using arcpy.Describe()

arcpy.Describe("test").catalogPath

will yield:

u'C:\\Users\\calebma\\AppData\\Local\\Temp\\arcF62A\\j8769f7ac2f5c46d0aa23afb2ddcd2a2a.gdb\\test'

enter image description here

I should mention this doesn't seem to work when referencing the "test" feature class by the test variable. I get an error that says "in_memory\test" does not exist.

enter image description here

Doing this for a feature layer will return the data source that the layer is created from. Feature Layers are a different animal than a feature class as it is just referencing a Feature Class.

  • @Dr.Ew I think the above answer is interesting, but overlooks that it is only when a feature class in an in_memory workspace has been used as the source of a layer that a temporary copy of it is held on disk. If you do arcpy.CopyFeatures_management(r'C:\temp\test.gdb\PointFC1',"in_memory/testFC") then arcpy.Describe("in_memory/testFC").catalogPath you will not see a disk location returned. – PolyGeo Sep 12 '14 at 23:15
  • @Dr.Ew Correct -> "the temporary location of the result of the MakeFeatureLayer is not the "in_memory" workspace" but a layer does NOT have to be added to a map. – PolyGeo Sep 13 '14 at 4:14
  • @PolyGeo I have not tested in stand alone, but I was able to return that full path to the in_memory location when ran in ArcMap's python window. That was using version 10.2.2. I was surprised though, I expected the return to be "in_memory\test". – crmackey Sep 13 '14 at 15:51
  • 1
    When I ran my two lines of code using ArcGIS 10.2.2 for Desktop from the Python window of ArcMap, what showed up in the Table of Contents List By Source View was a location of GPInMemoryWorkspace:{GUID}. This makes sense to me and I am unable to explain what you are seeing. Can you perhaps edit your answer to include your precise steps prior to observing what you did. In my case it was just to open ArcMap with a Blank Map, and then issue the two lines of code in the Python window. – PolyGeo Sep 14 '14 at 0:53
  • @PolyGeo Thanks for the suggestion. I added a screenshot of the code I ran. The copySchema is a custom function that just creates a new fc with the schema of another fc. I had never seen this behavior before, but it seems to only yield the full path to the temp directory when it is referenced by the layer from the TOC, otherwise I get an error that says the in memory fc doesn't exist. – crmackey Sep 15 '14 at 13:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.