Schema
汇总
数据集的 schema。
讨论
类型为要素类、表、栅格或工作空间的每个输出参数都具有 Schema 对象。 只有输出要素类、表、栅格和工作空间具有 schema,其他类型则没有。 Schema 对象在地理处理工具验证中创建。 可以通过参数对象访问此 schema,或者设置规则以描述工具的输出。 在验证中设置方案规则之后,地理处理内部验证代码会检查设置的规则并更新输出的描述。
属性
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
additionalChildren (读取和写入) |
将添加到工作空间方案的数据集的列表。 |
String |
|
additionalFields (读取和写入) |
将由该工具创建的其他字段。 这些字段是应用 |
Field |
|
cellSize (读取和写入) |
输出的像元大小。 当 |
Double |
|
cellSizeRule (读取和写入) |
指定输出栅格或格网的像元大小。
|
String |
|
clone (读取和写入) |
指定是否使用第一个依赖参数中的描述的精确复制(克隆)。 默认值为 |
Boolean |
|
extent (读取和写入) |
当 |
Extent |
|
extentRule (读取和写入) |
指定如何管理
|
String |
|
featureType (读取和写入) |
指定
|
String |
|
featureTypeRule (读取和写入) |
指定输出要素类的要素类型。 此规则对输出栅格或输出表不起作用。
|
String |
|
fieldsRule (读取和写入) |
指定将存在于输出要素类或表中的字段。
|
String |
|
geometryType (读取和写入) |
指定输出的几何类型。 当 |
String |
|
geometryTypeRule (读取和写入) |
指定输出要素类的几何类型(例如点或面)。
|
String |
|
rasterFormatRule (读取和写入) |
指定输出栅格的格式, |
String |
|
rasterRule (读取和写入) |
指定将包含在输出栅格中的数据类型。
|
String |
|
type (只读) |
指定输出方案类型: |
String |
代码示例
在 ToolValidator 类中,将输出参数的方案设置为第一个输入参数。
def initializeParameters(self):
# Set the dependencies for the output and its schema properties. The two
# input parameters are feature classes.
self.params[2].parameterDependencies = [0, 1]
# Feature type, geometry type, and fields all come from the first dependency
# (parameter 0), the input features.
self.params[2].schema.featureTypeRule = "FirstDependency"
self.params[2].schema.geometryTypeRule = "FirstDependency"
self.params[2].schema.fieldsRule = "FirstDependency"
# The extent of the output is the intersection of the input features and
# the clip features (parameter 1).
self.params[2].schema.extentRule = "Intersection"
return
可以使用 GetParameterInfo 函数查询特定工具输出参数的方案。
import arcpy
toolname = "Buffer_analysis"
parameter_index = 1
# Get the schema of the tool parameter
schema = arcpy.GetParameterInfo(toolname)[parameter_index].schema
properties = ['additionalChildren', 'additionalFields', 'cellSize',
'cellSizeRule', 'clone', 'extent', 'extentRule',
'featureType', 'featureTypeRule', 'fieldsRule',
'geometryType', 'geometryTypeRule', 'rasterFormatRule',
'rasterRule', 'type']
# Walk through all schema properties and print the value
for prop in properties:
try:
val = eval("schema." + prop)
print("{:<18} : {}".format(prop, val))
except (NameError, RuntimeError):
# Properties unsupported by the parameter data type will be ignored
pass