python批量替换数值

您所在的位置:网站首页 查车牌软件有哪些 python批量替换数值

python批量替换数值

#python批量替换数值| 来源: 网络整理| 查看: 265

importarcpy, os

#

该文件夹下的

mxd

将批量执行

mxdFolderPath = r"C:\temp\GJHY-16"

#

'r'

避免被转义

,

\t

#

旧的数据源

#

数据库连接

\orcl.sde

oldDataSources

=

r"C:\Users\Administrator\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\GJHY2.sde"

#

oldDataSources

=

r"C:\Users\Administrator\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\Connection

to

127.0.0.1.sde"

#

oldDataSources

=

r"C:\Users\Administrator\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\Connection

to

10.1.4.22.sde"

#

新的数据源

newDataSources

=

r"C:\Users\Administrator\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\GJHY.sde"

#

是否要求新数据源有效

validateNewDataSources = False

saveFolderPath = os.path.join(mxdFolderPath,"save")

if not os.path.exists(saveFolderPath):

os.mkdir(saveFolderPath)

for filename in os.listdir(mxdFolderPath):

fullpath = os.path.join(mxdFolderPath, filename)

ifos.path.isfile(fullpath):

basename, extension = os.path.splitext(filename)

ifextension.lower() == ".mxd":

mxd = arcpy.mapping.MapDocument(fullpath)

printfullpath

#debug

print "====================

更改前:

====================="

brknList = arcpy.mapping.ListBrokenDataSources(mxd)

print "BrokenDataSources

个数

:%d" % len(brknList)

print "

【数据源损坏的图层】

"

iflen(brknList)>0:

forlyr in brknList:

print "- " + lyr.name

print "\t" + lyr.dataSource

# print "

【所有图层】

"

# forlyr in arcpy.mapping.ListLayers(mxd):

#

print "- " + lyr.name

#

iflyr.supports("DATASOURCE"):



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3