切换版本 (Data Management)

许可等级:BasicStandardAdvanced

摘要

每个输入要素图层或表视图都需要修改各自的工作空间以便连接到所请求的版本。

用法

语法

ChangeVersion_management (in_features, version_type, {version_name}, {date})
参数说明数据类型
in_features

要通过指定版本连接到的输入要素图层或表视图。

Feature Layer
version_type

要更改到的版本类型。

  • TRANSACTIONAL连接到数据库的一种已定义状态。
  • HISTORICAL连接到表示过去某一特定时刻的版本,通常通过时间标记或历史标记指定。
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"))

环境

此工具不使用任何地理处理环境

相关主题

许可信息

ArcGIS for Desktop Basic:否
ArcGIS for Desktop Standard:是
ArcGIS for Desktop Advanced:是
9/15/2013