in_memory\ for geoprocessing in ArcGis Pro?

6523
15
10-08-2019 10:27 AM
LynnGaines
New Contributor III

In Arc Pro 2.6, the message ERROR 000210: Cannot create output memory\example is returned after I run my geoprocessing script.  The script is using Python 3.6.  

I understand that Arc PRO is different from ArcMap in that it is 64-bit and does not block the application while a tool is running.  I read, however, that the mulithreaded approach writes on-disk in PRO when using "in_memory\\example " and not to memory as I prefer.   Using "memory\example", seemed to be the solution, but then it results in the error mentioned above.

Can you please help me in identifying a way to write to memory as I did in ArcMap with the goal of publishing? Below is a bit of the code that I used.  Any help is appreciated.  

 

#Import arcpy modules

from arcpy import MakeQueryLayer_management
from arcpy import CopyFeatures_management
from arcpy import env

#Local Variables

LPRMQ = r"memory\LPRMQ"

#Input/Output

PIDNum = arcpy.GetParameterAsText(0)

arcpy.SetParameterAsText(1, r"memory\LPR")

#  Set Geoprocessing environments

arcpy.env.scratchWorkspace = "C:\\Users\\..."

arcpy.env.workspace = "C:\\Users\\..."

arcpy.MakeQueryLayer_management(DB, LPRMQ, "SELECT ...")

arcpy.CopyFeatures_management(LPRMQ, r"memory\LPR", "", "0", "0", "0")

Lynn

0 Kudos
15 Replies
Per_Åke_MattiasWallin
New Contributor III

Lynn,

Just for testing- can you simplify your script?  Can the issue be with your query layer?  The arcpy.CopyFeatures_management() command to a memory feature works just fine for me.  I am using ArcGIS Pro 2.4.2 by the way.

0 Kudos
LynnGaines
New Contributor III

Thank you for your reply.  I think the difference is using the interactive mode in PRO vs. standalone (arcpy from PyScripter).  For some reason, 'memory\' stores data in .gdb and not on-disk.  

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

In Pro 2.4.x and newer (possibly 2.3.x too), "memory" should store data sets in-memory when using the interactive Python window in Pro while "in_memory" will store data sets on disk.

Looking over the code provided, I am guessing the problem is that you are prefixing your layer name with "memory."  Query layers, feature layers, table views, etc... are stored in-memory by design, so having a layer name as r"memory\LPRMQ" carries a high risk of causing issues.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Sharing with Python‌ because this is an ArcPy question and not an ArcGIS API for Python question.

0 Kudos
LynnGaines
New Contributor III

Joshua,

Thank you for your reply.  I followed the example provided here in writing to memory.  It looks similar to in_memory and I thought that it would provide the expected results. I was wrong.  I believe that the example was using an interactive Python window. 

Thank you also for sharing my question with the Python group.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Your use of "memory" with Copy Features is correct because that tool outputs a feature class.  Make Feature Layer makes a feature layer within the application memory space, it doesn't output a data set. 

What results do you get if you change the following line:

LPRMQ = r"LPRMQ"

0 Kudos
LynnGaines
New Contributor III

Thank you Joshua for your response.  Unfortunately, I had to abandon this project in Arcgis Pro due to time constraints.  (It worked fine in ArcMap.)  I will use your suggestion when I revisit in_memory in ArcPro and include my results.

0 Kudos
deleted-user-3K8mKpoPb261
New Contributor III

Has this issue been resolved? I'm running to the same issue using ArcGIS Pro 2.5

0 Kudos
deleted-user-3K8mKpoPb261
New Contributor III

I just switched back to 2.4 which fixed it. But this could be a bigger problem though.

Could someone try to replicate the issue by running the following script using ArcGIS Pro 2.5?

arcpy.env.workspace = 'in_memory'

Do something

Then check if there's anything in the workspace using
arcpy.ListFeatureClasses()

I haven't used community.esri.com this much (to ask questions) until I switched from ArcMap to ArcGIS Pro. It makes me wonder if there are enough advanced ArcGIS users who actually upgrade to the recent versions of the software.