arcpy批量合并shp

# encoding: utf-8
import csv
import arcpy
import os
shuju=r"D:\short2.gdb"
arcpy.env.workspace=shuju
fcs=arcpy.ListFeatureClasses()
lspt = []
for fc in fcs:
    lspt.append(fc)

arcpy.Merge_management(lspt, "short")

在试验的时候发现,如果依次过大会不出结果,因此可以分割数组,分批次实现

# encoding: utf-8
import arcpy
import os
shuju=r"D:\short2.gdb"
arcpy.env.workspace=shuju
fcs=arcpy.ListFeatureClasses()
lspt = []
for fc in fcs:
    lspt.append(fc)
value=500
k=len(lspt)/500
for i in range(k):
    print i,i+1
    lsptls = lspt[i* value:(i+1) * value]
    arcpy.Merge_management(lsptls, r"D:\Desktop\yw"+"\\s"+str(i)+".shp")
arcpy.Merge_management(lspt[18* value:], r"D:\Desktop\yw"+"\\szz"+str(i)+".shp")

猜你喜欢

转载自blog.csdn.net/A873054267/article/details/87694116