HowTo: Set relative paths for all map documents in a folder using Python
【相关信息】
Article ID: 40656
Software:
ArcGIS for Desktop Advanced 10.1
ArcGIS for Desktop Standard 10.1
ArcGIS for Desktop Basic 10.1
Platforms:
Windows XP, Server 2003, Vista, Server 2008, Windows 7
【问题描述】
The map document properties provides the option to set relative paths for layers within the map document. The paths are stored as incomplete paths that are relative to the current location of the map document.
Article ID: 40656
Software:
ArcGIS for Desktop Advanced 10.1
ArcGIS for Desktop Standard 10.1
ArcGIS for Desktop Basic 10.1
Platforms:
Windows XP, Server 2003, Vista, Server 2008, Windows 7
【问题描述】
The map document properties provides the option to set relative paths for layers within the map document. The paths are stored as incomplete paths that are relative to the current location of the map document.
1 个回复
EsriSupport
赞同来自:
Relative paths can be set by opening the properties of a map document and choosing the option to store the relative paths of the data sources. This process can be time consuming if done one document at a time. However, the following Python script automates this process for all map documents within a folder.
import arcpy, os
#workspace to search for MXDs
Workspace = r"c:\Temp\MXDs"
arcpy.env.workspace = Workspace
#list map documents in folder
mxdList = arcpy.ListFiles("*.mxd")
#set relative path setting for each MXD in list.
for file in mxdList:
#set map document to change
filePath = os.path.join(Workspace, file)
mxd = arcpy.mapping.MapDocument(filePath)
#set relative paths property
mxd.relativePaths = True
#save map doucment change
mxd.save()
【其它相关参考】
【创建及修改时间】
Created: 11/12/2012
Last Modified: 7/12/2013
【原文链接】
http://support.esri.com/en/kno ... 40656
要回复问题请先登录或注册