Skip to main content

Schema

Summary

The schema of a dataset.

Discussion

Every output parameter of type feature class, table, raster, or workspace has a Schema object. Only output feature classes, tables, rasters, and workspaces have a schema—other types do not. The Schema object is created in geoprocessing tool validation. You access this schema through the parameter object and set the rules for describing the output of the tool. After you set the schema rules in validation, the geoprocessing internal validation code examines the rules you set and updates the description of the output.

Learn more about the Schema object

Properties

Name Explanation Data type

additionalChildren

(Read and Write)

A list of datasets that will be added to a workspace schema.

String

additionalFields

(Read and Write)

Additional fields that will be created by the tool. These fields are in addition to those added by the application of the fieldsRule property.

Field

cellSize

(Read and Write)

The cell size of the output. Use this property when the cellSizeRule property value is AsSpecified.

Double

cellSizeRule

(Read and Write)

Specifies the cell size of output rasters or grids.

  • AsSpecified—The output cell size will be specified using the cellSize property.

  • FirstDependency—The cell size will be calculated from the first dependent parameter. If the dependent parameter is a raster, the cell size of that raster will be used. For other types of dependent parameters, such as feature classes or feature datasets, the extent of the data will be used to calculate a cell size. If the first dependent parameter is a multivalue (a list of values), the first value will be used.

  • Max—The largest cell size of the dependent parameters will be used.

  • Min—The smallest cell size of the dependent parameters will be used.

  • Environment—The cell size will be calculated based on the Cell Size environment.

String

clone

(Read and Write)

Specifies whether an exact copy (clone) of the description in the first dependent parameter will be used. The default value is False.

Boolean

extent

(Read and Write)

The extent that will be used when the extentRule property value is AsSpecified. The extent can be set with a space-delimited string or a list with four values. The sequence is the minimum x, the minimum y, the maximum x, and the maximum y.

Extent

extentRule

(Read and Write)

Specifies how the extent property will be managed.

  • AsSpecified—The output extent will be specified in the extent property.

  • FirstDependency—The output extent will be the same as the first dependent parameter. If the first dependent parameter is a multivalue (a list of values), the first value in the multivalue list will be used.

  • Intersection—The output extent will be the geometric intersection of all dependent parameters.

  • Union—The output extent will be the geometric union of all dependent parameters.

  • Environment—The output extent will be calculated based on the Extent environment.

String

featureType

(Read and Write)

Specifies the feature type of the output when the featureTypeRule property value is AsSpecified.

  • Simple—The output will contain simple features. The geometry type of the features is specified by the geometryTypeRule property.

  • Annotation—The output will contain annotation features.

  • Dimension—The output will contain dimension features.

String

featureTypeRule

(Read and Write)

Specifies the feature type of the output feature class. This rule has no effect on output rasters or tables.

  • Unknown—The feature type will be unknown.Typically, you should be able to determine the geometry type in the updateParameters method based on the values of other parameters. Only set the property to Unknown when there is insufficient information to determine the feature type, such as in the initializeParameters method. This is the default.

  • AsSpecified—The feature type will be determined by the featureType property.

  • FirstDependency—The feature type will be the same as the first parameter in the dependencies. If the first dependent parameter is a multivalue (a list of values), the first value in the multivalue list will be used.

String

fieldsRule

(Read and Write)

Specifies the fields that will exist on the output feature class or table.

  • None—No fields will be output except the object ID fields.

  • FirstDependency—Output fields will be the same as the first dependent parameter. If the first dependent parameter is a multivalue (a list of values), the first value in the multivalue list will be used.

  • FirstDependencyFIDs—Only the object ID field of the first dependent input will be written to the output.

  • All—All fields in the list of dependent parameters will be output.

  • AllNoFIDs—All fields except the object ID fields will be written to the output.

  • AllFIDsOnly—All object ID fields will be written to the output, but no other fields from the inputs will be written.

String

geometryType

(Read and Write)

Specifies the geometry type of the output. The value can be Point, Multipoint, Polyline, or Polygon when the geometryTypeRule property value is AsSpecified.

String

geometryTypeRule

(Read and Write)

Specifies the geometry type (such as point or polygon) of the output feature class.

  • Unknown—The geometry type will be unknown.Typically, you should be able to determine the geometry type in the updateParameters method based on the values of other parameters. Only set the property to Unknown when there is insufficient information to determine the geometry type, such as in the initializeParameters method. This is the default.

  • FirstDependency—The geometry type will be the same as the first dependent parameter. If the first dependent parameter is a multivalue (a list of values), the first value in the multivalue list will be used.

  • Max—Sets the output geometry type to the maximum type of all dependent parameters.

  • Min—Examines the geometries of all dependent parameters and sets the output geometry type to the minimum type found.

  • AsSpecified—The geometry type will be determined by the geometryType property value.

String

rasterFormatRule

(Read and Write)

Specifies the output raster format, either GRID or Img. The default is Img, which is ERDAS IMAGINE format.

String

rasterRule

(Read and Write)

Specifies the data type that will be contained in the output raster.

  • FirstDependency—The data type (integer or float) will be the same as the first dependent parameter. If the first dependent parameter is a multivalue (a list of values), the first value in the multivalue list will be used.

  • Max—If there are dependent parameters that include integers and floats, the data type will be float.

  • Min—If there are dependent parameters that include integers and floats, the data type will be integer.

  • Integer—The data type will be integer.

  • Float—The data type will be float.

String

type

(Read only)

Specifies the output schema type: Feature, Table, Raster, or Container (for workspaces and feature datasets).

String

Code sample

Schema example 1

In a ToolValidator class, set the schema of the output parameter to the first input parameter.

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
Schema example 2

Interrogate the schema of a specific tool output parameter using the GetParameterInfo function.

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