切换版本 (数据管理)
摘要
每个输入要素图层或表视图都需要修改各自的工作空间以便连接到所请求的版本。
用法
-
仅适用于要素图层和表视图。
-
该工具不会编辑用于创建输入要素图层或表视图的 ArcSDE 连接文件。仅要素图层/表视图的开放工作空间会更改为连接到所指定的版本。
-
支持事务视图和历史视图。
语法
ChangeVersion_management (in_features, version_type, {version_name}, {date})
参数 | 说明 | 数据类型 |
in_features |
要通过指定版本连接到的输入要素图层或表视图。 | Feature Layer |
version_type |
要更改到的版本类型。
| String |
version_name (可选) |
要更改到的版本名称。如果使用的是历史版本,则此项为可选项。 | String |
date (可选) |
要更改到的历史版本的日期。 | Date |
代码示例
ChangeVersion 示例(Python 窗口)
以下 Python 窗口脚本演示了如何在即时模式下使用 ChangeVersion 函数。
import arcpy from arcpy import env env.workspace = r'Database Connections\toolbox.sde' arcpy.MakeFeatureLayer_management(r'TOOLBOX.Redlands\TOOLBOX.street', 'RedlandsStreets') arcpy.MakeFeatureLayer_management(r'TOOLBOX.Redlands\TOOLBOX.streams', 'RedlandsStreams') arcpy.MakeFeatureLayer_management(arcpy.SelectLayerByLocation_management("RedlandsStreams","WITHIN_A_DISTANCE","RedlandsStreets","100 Meters","NEW_SELECTION",'#'), 'StreamsNearStreets','','','') arcpy.ChangeVersion_management('RedlandsStreets','TRANSACTIONAL', 'TOOLBOX.proposedStreets2k9','') arcpy.MakeFeatureLayer_management(arcpy.SelectLayerByLocation_management("RedlandsStreams","WITHIN_A_DISTANCE","RedlandsStreets","100 Meters","NEW_SELECTION",'#'), 'NewStreamsNearStreets','','','')
ChangeVersion 示例(独立脚本)
在典型的版本化分析工作流中使用 ChangeVersion 工具。
# Name: ChangeVersion.py # Description: Use the ChangeVersion tool in a typical versioned analysis workflow. Quick check of additional # streams within a pre-determined distance of new proposed street development. # Author: ESRI # import system modules import arcpy from arcpy import env import sys, os # Set environments env.workspace = sys.path[0] + os.sep + "toolbox.sde" # Create the layers arcpy.MakeFeatureLayer_management(r'TOOLBOX.Redlands\TOOLBOX.street', 'RedlandsStreets') arcpy.MakeFeatureLayer_management(r'TOOLBOX.Redlands\TOOLBOX.streams', 'RedlandsStreams') # Perform analysis on the Default version to determine current number of streams within 100 meters of streets. arcpy.MakeFeatureLayer_management(arcpy.SelectLayerByLocation_management("RedlandsStreams","WITHIN_A_DISTANCE","RedlandsStreets","100 Meters","NEW_SELECTION",'#'), 'StreamsNearStreets','','','') print "Streams within 100 Meters of current streets: " + str(arcpy.GetCount_management("StreamsNearStreets")) # Change to the development version arcpy.ChangeVersion_management('RedlandsStreets','TRANSACTIONAL', 'TOOLBOX.proposedStreets2k9','') # Perform the same analysis on the development version to see the effect of the proposed changes. arcpy.MakeFeatureLayer_management(arcpy.SelectLayerByLocation_management("RedlandsStreams","WITHIN_A_DISTANCE","RedlandsStreets","100 Meters","NEW_SELECTION",'#'), 'NewStreamsNearStreets','','','') print "Streams projected to be within 100 Meters of streets after proposed street additions: " + str(arcpy.GetCount_management("NewStreamsNearStreets"))
环境
此工具不使用任何地理处理环境
相关主题
许可信息
ArcView: 否
ArcEditor: 是
ArcInfo: 是
7/10/2012