`ERROR 000468: Input shape types are not equal `

by user10680652   Last Updated December 06, 2018 15:22 PM

Trying to merge shapefiles:

#function

def get_folder(fn, k=-2):
    return os.path.split(fn)[0].split(os.sep)[k]

Code:

d = defaultdict(list)
with open(fi +'//' + 'exports' + '//'+'info.txt', 'w') as fw:
    for root, dirs, files in os.walk(fi):
        for shapefile in files:
            if shapefile.endswith('.shp'):
                arcpy.AddField_management(os.path.join(root,shapefile), "field_Tmp", "LONG")
                with arcpy.da.UpdateCursor(os.path.join(root,shapefile),'field_Tmp') as cursor:
                    for row in cursor:
                        row[0] = get_folder(os.path.join(root,shapefile))                   
                        cursor.updateRow(row)
                d[os.path.basename(shapefile)].append(os.path.join(root,shapefile)) 


for cat, lst in d.items():
     arcpy.Merge_management(cat,path_to_export')

ERROR 000732: Dataset ad1.shp does not exist or is not supported

Although it exists.

This is because it needs to do the merge 'by name'.

The list now is like this:

['C:\\Users\\user\\Desktop\\shape\\430\\ad1\\ad1.shp',
 'C:\\Users\\user\\Desktop\\shape\\430\\ad2\\ad2.shp',
 'C:\\Users\\user\\Desktop\\shape\\124\\ad1\\ad1.shp',
 'C:\\Users\\user\\Desktop\\shape\\124\\ad2\\ad2.shp']

So it has to merge:

'C:\\Users\\user\\Desktop\\shape\\430\\ad1\\ad1.shp' with
'C:\\Users\\user\\Desktop\\shape\\124\\ad1\\ad1.shp',

and

 'C:\\Users\\user\\Desktop\\shape\\430\\ad2\\ad2.shp', with
 'C:\\Users\\user\\Desktop\\shape\\124\\ad2\\ad2.shp'

I think this is the cause of the error.

Can you suggest a fix?

Tags : arcpy


Related Questions


Update Data Driven Pages Index layer via Python

Updated May 28, 2015 00:09 AM