4

I came across this post and found out about Copy_management().

Is it possible to copy an in_memory feature to another in_memory feature?

I tried to test it using the following code, which fails:

shp = r"D:\test\somefile.shp"

bufferOne = arcpy.Buffer_analysis(shp,r"in_memory\bufferOne",'1 meters')

copyOfFirst = arcpy.Copy_management(bufferOne,r'in_memory\BufferOneCopy')

Trying the exact same thing with absolute paths, instead of in_memory works fine. Therefore I assume you cannot copy from in_memory to in_memory, or am I missing something? Would there be a way to achieve the same effect?

1
  • What do you mean by "fails"? Did you get an ERROR 000260 or something else?
    – PolyGeo
    Commented Aug 25, 2015 at 9:18

2 Answers 2

3

Yes, you can. Use the Copy_Features GP tool for that.

pnt_fc = r"C:\Users\us\Documents\ArcGIS\Default.gdb\_PointDistanceFc"

mem1 = r"in_memory\bufferOne"
mem2 = r"in_memory\bufferTwo"

arcpy.Buffer_analysis(in_features=pnt_fc,
                      out_feature_class=mem1,
                      buffer_distance_or_field='10 Meters')

arcpy.CopyFeatures_management(mem1,mem2)

arcpy.CopyFeatures_management(mem2,r"C:\Users\us\Documents\ArcGIS\Default.gdb\out123")

When you use the following approach:

mem1 = arcpy.Buffer_analysis(in_features=pnt_fc,
                      out_feature_class=r"in_memory\bufferOne",
                      buffer_distance_or_field='10 Meters')

mem2 = arcpy.CopyFeatures_management(mem1,r"in_memory\bufferTwo")

arcpy.CopyFeatures_management(mem2,r"C:\Users\us\Documents\ArcGIS\Default.gdb\out123")

You are getting mem1 and mem2 of type <class 'arcpy.arcobjects.arcobjects.Result'>, you should be aware of this if you are planning to interact with those objects.

4
  • It's Copy_management not CopyFeatures_management being used.
    – PolyGeo
    Commented Aug 25, 2015 at 9:15
  • True, but the question was "My question is if it is possible to copy an in_memory feature to another in_memory feature." Commented Aug 25, 2015 at 9:16
  • You're right - I was distracted by the title which did not fully summarize the content.
    – PolyGeo
    Commented Aug 25, 2015 at 9:19
  • The reason I ended up working with Copy_management is because CopyFeatures_management always spits out an error message for me when trying to save into memory, so I assumed it cannot be used to save into memory. I will have to try your code snippet later, and I will let you know. Commented Aug 25, 2015 at 13:19
1

It is not possible to save the output of the Copy tool to in_memory, whatever the input's workspace. It is explained in the last answer of the post you mentioned, I add here an updated reference.

FYI, there are some other tools that don't accept in_memory as output workspace, e.g. Project.

1
  • 2
    I agree - Copy_management can only be used between workspaces of the same type. Otherwise an ERROR 000260 will result.
    – PolyGeo
    Commented Aug 25, 2015 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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