Schema (arcpy)
Récapitulatif
The schema of a dataset.
Discussion
Every output parameter that is of feature class, table, raster, or workspace type has a schema object.
Propriétés
Propriété | Explication | Type de données |
additionalChildren (Lecture/écriture) |
Python list of datasets to add to a workspace schema. | String |
additionalFields (Lecture/écriture) |
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 (Lecture/écriture) |
Set this to the cell size to use when cellSizeRule is AsSpecified. | Double |
cellSizeRule (Lecture/écriture) |
Determines the cell size of output rasters or grids.
| String |
clone (Lecture/écriture) |
If True, make an exact copy (clone) of the description in the first dependent parameter. The default value is False. | Boolean |
extent (Lecture/écriture) |
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 (Lecture/écriture) |
Indicates how the extent property is to be managed.
| String |
featureType (Lecture/écriture) |
When the featureTypeRule is AsSpecified, the value in FeatureType is used to specify the feature type of the output.
| String |
featureTypeRule (Lecture/écriture) |
This setting determines the feature type of the output feature class. This rule has no effect on output rasters or tables.
| String |
fieldsRule (Lecture/écriture) |
Determines what fields will exist on the output feature class or table.
| String |
geometryType (Lecture/écriture) |
Set this to the geometry type to use (either Point, Multipoint, Polyline, or Polygon) when geometryTypeRule is AsSpecified. | String |
geometryTypeRule (Lecture/écriture) |
This setting determines the geometry type (such as point or polygon) of the output feature class.
| String |
rasterFormatRule (Lecture/écriture) |
This determines the output raster format, either GRID or Img. The default is Img, which is ERDAS IMAGINE format. | String |
rasterRule (Lecture/écriture) |
This determines the data type—integer or float—contained in the output raster.
| String |
type (Lecture seule) |
The schema type: Feature, Table, Raster, or Container (for workspaces and feature datasets). | String |
Exemple de code
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
Interrogate the schema of a specific tool parameter
import arcpy
toolname = "Buffer_analysis"
parameter = 0
# Get the schema of the tool parameter
#
schema = arcpy.GetParameterInfo(toolname)[parameter].schema
properties = ['additionalChildren', 'additionalFields', 'cellSize',
'cellSizeRule', 'clone', 'extent', 'extentRule',
'featureType', 'featureTypeRule', 'fieldsRule',
'geometryType', 'geometryTypeRule', 'rasterFormatRule',
'rasterRule', 'type']
# Walk through all schema property and print out the value
#
for property in properties:
try:
print "%s : %s" % (property, eval("schema." + property))
except:
print property