I'm attempting to use the merge function arcpy.management.Merge(inputs, output) but I am not getting the results I expect. I have a list of featureclasses (all polygon, all have the same fields) in the in_memory workspace:
['in_memory\\polygon_D0511', 'in_memory\\polygon_D0510', 'in_memory\\polygon_D0512', 'in_memory\\polygon_D3239', 'in_memory\\polygon_D0514', 'in_memory\\polygon_D0515', 'in_memory\\polygon_D0513', 'in_memory\\polygon_D0509']
and I am using that as my inputs. The output is in a local geodatabase. When I run the merge tool in the script, my output only contains the feature from 'in_memory\\polygon_D3239', and nothing else. I've looked in my in_memory workspace using the arcpy.ListFeatureClasses() function and found that all featureclasses listed are there. I'm at a loss.. can anybody shed some light on this?
Thank you so much for any help at all!
Hi Dan, thank you for the suggestion. I tried this after changing my script to save to a file geodatabase (instead of the in_memory workspace) and the merge worked just fine. However, attempting to do this same operation in script did not work even when using a file geodatabase instead of the in_memory workspace.
From the merge tool documentation I can see that the input should be a list of data filepaths, which is exactly what I am using for the input. The following code snippet is essentially* what I am doing in the script
damarea = "C:\\temp.gdb
damarea_list = ['in_memory\\polygon_D0511', 'in_memory\\polygon_D0510', 'in_memory\\polygon_D0512', 'in_memory\\polygon_D3239', 'in_memory\\polygon_D0514', 'in_memory\\polygon_D0515', 'in_memory\\polygon_D0513', 'in_memory\\polygon_D0509']
arcpy.env.workspace = "in_memory"
*I am leaving out a for loop where I first develop the individual featureclasses and then append them to the final list that you see in damarea_list.
The field mapping parameter is optional and since all input featureclasses have the exact same fields, I do not think I need it for the merge tool to work?
P.S. I did see that when I export to python from model builder, the input featureclasses is not provided as a list, but as a string with filepaths separated by a semicolon (;). I tried this in the script and it also did not work. Any other ideas?? I am at a loss and appreciate any help I can get here.
The parameters would be a semi-colon list of strings, but you parse the string.
a_list = "some;big;long;string;of;files".split(";") a_list Out: ['some', 'big', 'long', 'string', 'of', 'files']
I am not convinced that the inmemory workspace is the best for this. If saving to a geodatabase worked, keep using it, do the merge there and use Copy tool to copy/move the results to its ultimate destination, then Delete the temporary geodatabase.... something about the double-backslashes is ringing a bell... try single then abandon in_memory if that doesn't work
I have this exact same problem and it's getting really frustrating troubleshooting something that should be so basic. Do you remember if this was ever solved? Any other ideas Dan Patterson? It only includes one feature class in the merge output in both ArcGIS Pro and ArcMap.