设置值域范围 (数据管理)

许可等级:BasicStandardAdvanced

摘要

设置现有值域范围的最小值和最大值。

用法

语法

SetValueForRangeDomain_management (in_workspace, domain_name, min_value, max_value)
参数说明数据类型
in_workspace

包含要更新的属性域的地理数据库。

Workspace
domain_name

要更新的值域范围的名称。

String
min_value

值域范围的最小值。

String
max_value

值域范围的最大值。

String

代码实例

设置值域范围示例(Python 窗口)

以下 Python 窗口脚本演示了如何在即时模式下使用 SetValueForRangeDomain 函数。

import arcpy
from arcpy import env
env.workspace =  "C:/data"
arcpy.SetValueForRangeDomain_management("montgomery.gdb", "RotAngle", 0, 359)
设置值域范围示例 2(独立脚本)

此独立脚本在创建属性范围域的工作流中使用 SetValueForRangeDomain 函数。

# Name: CreateRangeDomain.py
# Purpose: Create an attribute domain to constrain valid rotation angle
# Author: ESRI

# Import system modules
import arcpy
from arcpy import env
 
try:
    # Set the workspace (to avoid having to type in the full path to the data every time)
    env.workspace = "C:/data"
 
    # Set local parameters
    dWorkspace = "montgomery.gdb"
    domName = "RotAngle2"
    domDesc = "Valid rotation angle"
    minRange = 0
    maxRange = 359
    inFeatures = "Montgomery.gdb/Water/fittings"
    inField = "ANGLE"
 
    # Process: Create the range domain
    arcpy.CreateDomain_management(dWorkspace, domName, domDesc, "LONG", "RANGE")
 
    # Process: Set the minimum and maximum values for the range domain
    arcpy.SetValueForRangeDomain_management(dWorkspace, domname, minRange, maxRange)
 
    # Process: Constrain the fitting rotation angle
    arcpy.AssignDomainToField_management( inFeatures, inField, domName)
 
except Exception, e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "Line %i" % tb.tb_lineno
    print e.message

环境

相关主题

许可信息

ArcGIS for Desktop Basic: 是
ArcGIS for Desktop Standard: 是
ArcGIS for Desktop Advanced: 是
5/10/2014