Arcpy 复制数据库
分别按照要素类、表格、要素数据集、栅格数据集分别将数据存储到新的数据库
import arcpy
from arcpy import env
import os
# Allow for the overwriting of file geodatabases, if they already exist #
env.overwriteOutput = True
# Set workspace to folder containing personal geodatabases #
env.workspace = arcpy.GetParameterAsText(0)
# Identify personal geodatabases #
for pgdb in arcpy.ListWorkspaces("*", "FileGDB"):
# Set workspace to current personal geodatabase#
print pgdb
env.workspace = pgdb
# Create file geodatabase based on personal geodatabase#
fgdb = pgdb[:-4] + "2.gdb"
arcpy.CreateFileGDB_management(os.path.dirname(fgdb), os.path.basename(fgdb))
# Identify feature classes and copy to file gdb #
for fc in arcpy.ListFeatureClasses():
print "Copying feature class " + fc + " to " + fgdb
arcpy.Copy_management(fc, fgdb + os.sep + fc)
# Identify tables and copy to file gdb #
for table in arcpy.ListTables():
print "Copying table " + table + " to " + fgdb
arcpy.Copy_management(table, fgdb + os.sep + table)
# Identify datasets and copy to file gdb
# Copy will include contents of datasets#
for dataset in arcpy.ListDatasets():
print "Copying dataset " + dataset + " to " + fgdb
arcpy.Copy_management(dataset, fgdb + os.sep + dataset)
转载自:https://blog.csdn.net/sprintwater/article/details/40052675