0

I am working with Jupyter notebooks in ArcGIS Pro and would like to write some Feature layers to memory to speed up my operation. Currently it is taking roughly 24 hours. I have to emphasize it is very important that they are written to memory as a feature layer and not a feature class, otherwise my code will not run correctly. I have found that I can get my point feature layers written to memory using the code below. However rewriting the layer to memory such as in a loop causes Pro to crash.

arcpy.management.CopyFeatures('ServiceLocation', "memory/ServiceLocationCopy") 

I have tried deleting the feature layer from memory before writing again and it still causes crashing. It is a hard crash without any errors given and just gives me the option to send a crash report. The code below will reliably cause my system to crash.

arcpy.management.CopyFeatures('ServiceLocation', "memory/ServiceLocationCopy") arcpy.Delete_management("memory/ServiceLocationCopy") arcpy.management.CopyFeatures('ServiceLocation', "memory/ServiceLocationCopy") 

Currently I am running ArcGIS Pro 3.0.2, due to company policies I am unable to make any updates to my system. ServiceLocation is a simple point feature layer with no z values. I am wondering if this operation will cause Pro to crash for other users and if there is another way to write feature layers to memory that will not cause crashes.

4
  • 1
    Your distinction between feature layers and feature classes seems out of place. A layer is the plotting manifestation of a feature class (which is just data). Both in-memory and disk-based feature classes exist outside of a layer, but a layer can't exist without a source. Tools which expect a layer will accept a feature class, because creating a "Miranda layer" is a trivial exercise. Commented Mar 28, 2024 at 23:26
  • @Vince the distinction is specific to my use case. Layers pass their selection when used to export features. Feature classes loose the selection and the entire extent is exported. Not sure why they are acting this way and it could be related to something else I am doing but I know the feature layers will behave as desired. Commented Mar 29, 2024 at 15:23
  • But the data has to be written to a feature class, and can't be written to a layer -- Layers are only pointers to data sources, not data sources themselves. Yes, they provide selection sets, and allow you to trim the column list, but they can only be read and written through, not read and written to. Commented Mar 29, 2024 at 17:23
  • @Vince Ok that is good information. I found some interesting behavior. Calling print(arcpy.Describe("ServiceLocationCopy").dataType) returns FeatureLayer while calling print(arcpy.Describe("memory/ServiceLocationCopy").dataType) returns FeatureClass. Using "memory/ServiceLocationCopy" in functions does not provide selections however using "ServiceLocationCopy" does. In the end after I got everything working using the fix below my code was just as slow as before using memory. Looping is slow without the use of dictionaries which I'm still learning. Commented Apr 1, 2024 at 15:42

1 Answer 1

2

This may be related to BUG-000138150...I'm testing its resolution in 3.2 now.

3
  • Good info. I will test with the recommended resolutions. Thanks. Commented Mar 28, 2024 at 22:58
  • Accepting your answer. I was able to verify things this morning and am able to write a feature layer to memory now after reading the bug report and following their suggested work around of arcpy.env.workspace = arcpy.env.scratchGDB. Much thanks. Commented Mar 29, 2024 at 15:58
  • cool, understood Commented Mar 29, 2024 at 20:29

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.