2

I have created a script to convert GPX into features with python. This script works but now I want to add all these separate feature classes (point features) in one featureclass/layer and convert it into a line feature. The following is the coding I did to merge the layers.

import arcpy
import os

arcpy.env.overwriteOutput = True
MergeFolder = "D:\Altwym_2017\programmeren\Geo_data.gdb"
Total = "D:\Altwym_2017\programmeren\output\total"
arcpy.env.workspace =MergeFolder

Mylist= arcpy.ListFeatureClasses(feature_type= "point")

arcpy.Merge_management (Mylist, Total)

The following Error occurs;

Traceback (most recent call last): File "D:/Altwym_2017/programmeren/scripts/Merge.py", line 13, in arcpy.Merge_management (Mylist, Total) File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\management.py", line 4124, in Merge raise e ExecuteError: ERROR 999999: Error executing function. Failed to execute (Merge).

I think the listing is the problem since no error occurs if I replace the Mylist with the actual filenames of the converted GPX files. Does anyone know how I should change my way of listing (or use some other function/command to select a huge amount of files).

Filling in/ using some function for finding the right names is not possible since the names have nothing in common.

3
  • Start by adding an r in front of the paths, for example: r"D:\Altwym_2017\programmeren\Geo_data.gdb"
    – BERA
    Aug 16, 2017 at 13:12
  • It did do something. Now i have the following error;
    – M. Heynen
    Aug 16, 2017 at 13:15
  • Traceback (most recent call last): File "D:/Altwym_2017/programmeren/scripts/Merge.py", line 13, in <module> arcpy.Merge_management (Mylist, Total) File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\management.py", line 4124, in Merge raise e ExecuteError: ERROR 000210: Cannot create output D:\Altwym_2017\programmeren\output\total Failed to execute (Merge).
    – M. Heynen
    Aug 16, 2017 at 13:15

1 Answer 1

2

The layer paths need the preceding "r" if your using back slashes alternatively you may use forward slashes "/" instead. Also the second parameter of the merge method needs to be a feature class, not just a directory, try:

Merge_management (inputs, output, {field_mappings})

MergeFolder = r"D:\Altwym_2017\programmeren\Geo_data.gdb"
Total = r"D:\Altwym_2017\programmeren\output.gdb\myMergeLayer"

OR

MergeFolder = "D:/Altwym_2017/programmeren/Geo_data.gdb"
Total = "D:/Altwym_2017/programmeren/output.gdb/myMergeLayer"

Also, you have a space in the merge statement between the "t" in managemen"t" and the first parentheses, use:

arcpy.Merge_management(Mylist, Total)
6
  • I get the following error: Traceback (most recent call last): File "D:/Altwym_2017/programmeren/scripts/Merge.py", line 13, in <module> arcpy.Merge_management (Mylist, Total) File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\management.py", line 4124, in Merge raise e ExecuteError: ERROR 000210: Cannot create output D:\Altwym_2017\programmeren\output\total\myMerge.shp Failed to execute (Merge).
    – M. Heynen
    Aug 16, 2017 at 13:24
  • I also tried to use the following directory; Total = r"D:\Altwym_2017\programmeren\output\total.shp Since the output is a geodatabase and the total was an existing feature layer in which I wanted to merge the GPX files in. Maybe a cause of the error could be because the the output is in a different geodatabase?
    – M. Heynen
    Aug 16, 2017 at 13:27
  • I seem to get the following error; Traceback (most recent call last): File "D:/Altwym_2017/programmeren/scripts/Merge.py", line 13, in <module> arcpy.Merge_management(Mylist, Total) File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\management.py", line 4124, in Merge raise e ExecuteError: ERROR 000210: Cannot create output D:\Altwym_2017\programmeren\output\myMerge.shp Failed to execute (Merge).
    – M. Heynen
    Aug 16, 2017 at 13:31
  • The output currently is looking for a directory called "output" located D:\Altwym_2017\programmeren, does the "output" directory exist?
    – artwork21
    Aug 16, 2017 at 13:31
  • yes the output directory exists, it is a geodatabase
    – M. Heynen
    Aug 16, 2017 at 13:31

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.