摘要
数据集的 schema。
说明
类型为要素类、表、栅格或工作空间的每个输出参数都具有 Schema 对象。 只有输出要素类、表、栅格和工作空间具有 schema,其他类型则没有。 Schema 对象在地理处理工具验证中创建。 可以通过参数对象访问此 schema,或者设置规则以描述工具的输出。 在验证中设置方案规则之后,地理处理内部验证代码会检查设置的规则并更新输出的描述。
属性
| 属性 | 说明 | 数据类型 |
| additionalChildren (可读写) | 将添加到工作空间方案的数据集的列表。 | String |
| additionalFields (可读写) | 将由该工具创建的其他字段。 这些字段是应用 fieldsRule 属性添加的字段之外的字段。 | Field |
| cellSize (可读写) | 输出的像元大小。 当 cellSizeRule 属性值为 AsSpecified 时,使用此属性。 | Double |
| cellSizeRule (可读写) | 指定输出栅格或格网的像元大小。
| String |
| clone (可读写) | 指定是否使用第一个依赖参数中的描述的精确复制(克隆)。 默认值为 False。 | Boolean |
| extent (可读写) | 当 extentRule 属性值为 AsSpecified 时将使用的范围。 可以使用空格分隔的字符串或具有四个值的列表来设置范围。 顺序为最小 x 值、最小 y 值、最大 x 值和最大 y 值。 | Extent |
| extentRule (可读写) | 指定如何管理 extent 属性。
| String |
| featureType (可读写) | 指定 featureTypeRule 属性值为 AsSpecified 时输出的要素类型。
| String |
| featureTypeRule (可读写) | 指定输出要素类的要素类型。 此规则对输出栅格或输出表不起作用。
| String |
| fieldsRule (可读写) | 指定将存在于输出要素类或表中的字段。
| String |
| geometryType (可读写) | 指定输出的几何类型。 当 geometryTypeRule 属性值为 AsSpecified 时,值可以为 Point、Multipoint、Polyline 或 Polygon。 | String |
| geometryTypeRule (可读写) | 指定输出要素类的几何类型(例如点或面)。
| String |
| rasterFormatRule (可读写) | 指定输出栅格的格式,GRID 或 Img。 默认值为 Img,它是 ERDAS IMAGINE 格式。 | String |
| rasterRule (可读写) | 指定将包含在输出栅格中的数据类型。
| String |
| type (只读) | 指定输出方案类型:Feature、Table、Raster 或 Container(针对工作空间和要素数据集)。 | 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