【批量代码分享】不同gdb批量投影 批量要素类复制

不同gdb批量投影

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#coding:utf-8
import arcpy
import os
arcpy.env.workspace = "C:\\Users\\Esri\\Desktop\\test__20160919\\qian"
arcpy.env.overwriteOutput = True
outWorkspace = "C:\\Users\\Esri\\Desktop\\test__20160919\\hou"
workspacess = arcpy.ListWorkspaces("*", "FileGDB")
for filenamegdb in os.listdir(arcpy.env.workspace):
arcpy.CreateFileGDB_management(outWorkspace,filenamegdb)
for workspace in workspacess:
walk = arcpy.da.Walk(workspace, datatype="FeatureClass")
for dirpath, dirnames, filenames in walk:
for filename in filenames:
facname=os.path.join(dirpath, filename)
asss=dirpath.split("\\")[-1]
outfea = os.path.join(outWorkspace,asss,filename)
arcpy.Project_management(facname,outfea,"PROJCS['CGCS2000_GK_CM_117E',GEOGCS['GCS_China_Geodetic_Coordinate_System_2000',DATUM['D_China_2000',SPHEROID['CGCS2000',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Gauss_Kruger'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',117.0],PARAMETER['Scale_Factor',1.0],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]", "", "GEOGCS['GCS_China_Geodetic_Coordinate_System_2000',DATUM['D_China_2000',SPHEROID['CGCS2000',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")

批量要素类复制

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# Pretreatment.py
# Created on: 2016-09-22
# (generated
# Description:。
# Import arcpy module
import os
import arcpy
inputDir = "C:\\Users\\Esri\\Desktop\\testdata"
Output = "C:\\Users\\Esri\\Desktop\\new"
arcpy.env.workspace = "C:\\Users\\Esri\\Desktop\\testdata"
workspacess = arcpy.ListWorkspaces("*","Access")
for workspace in workspacess:
asss = workspace.split("\\")[-1]
arcpy.CreatePersonalGDB_management(Output, asss)
dimao=os.path.join(workspace,u"地貌")
walk = arcpy.da.Walk(dimao, datatype="FeatureClass")
for root, dirs, files in walk:
for f in files:
fc=os.path.join(dimao,f)
out_data =os.path.join(Output,asss,f)
arcpy.Copy_management(fc, out_data)
print("处理完成")