合并不同gdb下的相同要素_Arcpy批量合并多个gdb中相同的要素类

Arcpy批量合并多个gdb中相同的要素类,流程为:

1、将所有的gdb放在一个目录下,即代码中的inpath (path_allgdb_except_one)

2、剪切一个gdb作为合并后的输出gdb,即代码中的outgdb (one.gdb)

3、执行下面脚本 (arcgis10.3成功)

# -*- coding: cp936 -*- #

import os

import sys

import arcpy

inpath = r"D:\path_allgdb_except_one"

outgdb = r"D:\one.gdb"

arcpy.env.workspace = inpath

# list all file geodatabases in the current workspace

workspaces = arcpy.ListWorkspaces("*", "FileGDB")

for j, workspace in enumerate(workspaces):

print('processing: ' + workspace)

arcpy.env.workspace = workspace

featureclasses = arcpy.ListFeatureClasses()

for i, fc in enumerate(featureclasses):

# print(' ' + fc)

output = os.path.join(outgdb, os.path.splitext(fc)[0])

# print output

arcpy.Append_management(fc, output)

你可能感兴趣的:(合并不同gdb下的相同要素)