Batch merging field mapping

المشرف العام

Administrator
طاقم الإدارة
I made the following script to merge shape files of different format types (poly,line, points):

def main(): import arcpy from arcpy import env import globalpath import os env.workspace = globalpath.toolDataPath dataPath=globalpath.toolDataPath arcpy.env.overwriteOutput = True #try: DataTypeL=[("Polygon","mergedTOTPoly.shp"),("Polyline","mergedTOTLines.shp"),("Point","MergedTOTPoint.shp")] for dType in DataTypeL: (Typei,Title)=dType matches = [] counter=0 for dirpath, dirnames, filenames in arcpy.da.Walk(dataPath+"\\UtilityDataFromZorgel",datatype="FeatureClass",type=Typei): for filename in filenames: match = ( os.path.join(dirpath, filename)) arcpy.AddMessage(m) matches.append (match) counter = counter + 1 arcpy.Merge_management(matches, dataPath+"\\utilities"+Title) arcpy.AddMessage(counter+" "+Typei+" layers were merged into "+ filename) #except: arcpy.AddWarning("Merging Utility Layers Failed")if __name__ == "__main__": main()I get the following error:

Traceback (most recent call last): File "C:\merger.py", line 30, in main() File "C:\merger.py", line 25, in main arcpy.Merge_management(matches, dataPath+"\\utilities"+Title) File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\management.py", line 3762, in Merge raise eExecuteError: ERROR 001156: Failed on input OID 0, could not write value 'Kanata' to output field TILE_IDFailed to execute (Merge).When I merge these files manually from arcmap it works, and fields are mapped as follows:

"STRUCT_TYP \"STRUCT_TYP\" true true false 18 Text 0 0 ,First,#,Allstream_hdwr_L,STRUCT_TYP,-1,-1,allstream_L,STRUCT_TYP,-1,-1,Allstream_lines_L,STRUCT_TYP,-1,-1,Allstream_text_L,STRUCT_TYP,-1,-1,Atria_lines_L,STRUCT_TYP,-1,-1,Atria_text_L,STRUCT_TYP,-1,-1,bell_L,STRUCT_TYP,-1,-1)

where STRUCT_TYP is a shared field.

please let me know how can I get around this error, and if it is indeed mapping the fields how can I do it in batched merging, or should I merge each file individually?



أكثر...
 
أعلى