1

I have several shapefiles I need to merge. I have been successful in merging all of them except for one using the code bellow. For the one that is not working, I get an error message that reads:

Traceback (most recent call last):
  File "H:\scripts\sanitary_merge.py", line 19, in <module>
    arcpy.Merge_management(feature_classes, outshp)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\management.py",
 line 4124, in Merge 
    raise e 
ExecuteError: ERROR 000302: The input feature types do not match
Failed to execute (Merge).

I added in the Walk function, hoping that will fix it, but it is not working still.

Code:

import arcpy
import fnmatch, os

workspace = 'E:\GPS\GPSDATA'
outdir = 'E:\GPS\GPSDATA\GPS_merge_layers'
search = 'Sanitary.shp'
outname = 'Merge_18.shp'

feature_classes = [] #Empty list to collect shapes.

walk = arcpy.da.Walk(workspace, datatype="FeatureClass", type="Point")

for dirpath, dirnames, filenames in walk:
    for filename in filenames:
        feature_classes.append(os.path.join(dirpath, filename))

if feature_classes:
    outshp = os.path.join(outdir, os.path.basename(outname[0][:-4]) + 'tanya_Sanitary.shp')
    arcpy.Merge_management(feature_classes, outshp)
  • 1
    Welcome to GIS SE! As a new user please take the tour to learn about our focused Q&A format. – Midavalo May 10 '17 at 19:02
  • 1
    Please edit your question to include the entire error message text, including line numbers. – Midavalo May 10 '17 at 19:03
  • 1
    What is the geometry type of your two shapefiles you are trying to merge? – Midavalo May 10 '17 at 19:03
  • you can't merge different geometry types (points cant be merge with polygons, etc.) – NULL.Dude May 10 '17 at 19:08
  • 2
    Check your files for "Multipoint" features. Another conflict is possible if some of your data has Z-value and some doesn't. – Serge Norin May 11 '17 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.