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 for you in geoprocessing tool validation. You access this schema through the parameter object and set the rules for describing the output of your 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

PropertyExplanationData Type
additionalChildren
(Read and Write)

Python list of datasets to add to a workspace schema.

String
additionalFields
(Read and Write)

Indicates additional fields for the fields property. Besides the fields that are added by the application of the fieldsRule, you can add additional fields to the output.

Field
cellSize
(Read and Write)

Set this to the cell size to use when cellSizeRule is AsSpecified.

Double
cellSizeRule
(Read and Write)

Determines the cell size of output rasters or grids.

  • AsSpecifiedThe output cell size is specified in the cellSize property.
  • FirstDependencyThe cell size is calculated from the first dependent parameter. If the dependent parameter is a raster, then its cell size is used. For other types of dependent parameters, such as feature classes or feature datasets, the extent of the data is used to calculate a cell size. If the first dependent parameter is a multivalue (a list of values), the first value in the multivalue list is used.
  • MaxThe largest cell size of the dependent parameters.
  • MinThe smallest cell size of the dependent parameters.
  • EnvironmentThe cell size is calculated based on the cell size environment setting.
String
clone
(Read and Write)

If True, make an exact copy (clone) of the description in the first dependent parameter. The default value is False.

Boolean
extent
(Read and Write)

Set this to the extent to use when extentRule is AsSpecified. You can either set the extent with a space-delimited string or a Python list object with four values. The sequence is xmin, ymin, xmax, ymax.

Extent
extentRule
(Read and Write)

Indicates how the extent property is to be managed.

  • AsSpecifiedThe output extent will be specified in the Extent property.
  • FirstDependencyThe output extent is 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 is used.
  • IntersectionThe output extent will be the geometric intersection of all dependent parameters.
  • UnionThe output extent will be the geometric union of all dependent parameters.
  • EnvironmentThe output extent will be calculated based on the output extent environment setting.
String
featureType
(Read and Write)

When the featureTypeRule is AsSpecified, the value in FeatureType is used to specify the feature type of the output.

  • SimpleThe output will contain simple features. The geometry type of the features is specified with geometryTypeRule.
  • AnnotationThe output will contain annotation features.
  • DimensionThe output will contain dimension features.
String
featureTypeRule
(Read and Write)

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

  • AsSpecifiedThe feature type will be determined by the featureType property.
  • FirstDependencyThe 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 is used.
String
fieldsRule
(Read and Write)

Determines what fields will exist on the output feature class or table.

  • NoneNo fields will be output except for the object ID.
  • FirstDependencyOutput 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 is used.
  • FirstDependencyFIDsOnly the ObjectID of the first dependent input will be written to the output.
  • AllAll fields in the list of dependent parameters will be output.
  • AllNoFIDsAll fields except for the ObjectIDs will be written to the output.
  • AllFIDsOnlyAll ObjectID fields are written to the output, but no other fields from the inputs will be written.
String
geometryType
(Read and Write)

Set this to the geometry type to use (either Point, Multipoint, Polyline, or Polygon) when geometryTypeRule is AsSpecified.

String
geometryTypeRule
(Read and Write)

This setting determines the geometry type (such as point or polygon) of the output feature class.

  • UnknownThis is the default setting. Typically, you should be able to determine the geometry type in updateParameters() based on the values of other parameters. You'd only set the rule to Unknown if you don't have enough information to determine the geometry type, such as in initializeParameters().
  • FirstDependencyThe geometry type is 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 is used.
  • MaxExamines the geometries of all dependent parameters and sets the output geometry type to the maximum type found.
  • MinExamines the geometries of all dependent parameters and sets the output geometry type to the minimum type found.
  • AsSpecifiedThe geometry type will be determined by the value of the geometryType property.
String
rasterFormatRule
(Read and Write)

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

String
rasterRule
(Read and Write)

This determines the data type—integer or float—contained in the output raster.

  • FirstDependencyThe data type (integer or float) is 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 is used.
  • MaxIf there are dependant parameters that include integers and floats, Max creates a float output.
  • MinIf there are dependant parameters that include integers and floats, Min creates an integer output.
  • IntegerThe output raster contains integers.
  • FloatThe output raster contains floats.
String
type
(Read Only)

The 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 out the value
for prop in properties:
    try:
        val = eval("schema." + prop)
        print("{:<18} : {}".format(prop, val))
    except (NameError, RuntimeError):
        # Properties unsupported by the parameter datatype will be ignored
        pass

Related topics