CreateObject

摘要

用于创建地理处理对象。 可使用额外的参数来指定创建对象所需的附加要求,例如 ValueTable 对象中的列数。

说明

注:

与使用 CreateObject 相比,使用等效 ArcPy 类要更为方便和直接。 例如,可使用 arcpy.Array() 来替代 arcpy.CreateObject("array")

语法

CreateObject (name, {options})
参数说明数据类型
name

The name of the object to be created (ArcSDESQLExecute, Array, Extent, FeatureSet, Field, FieldInfo, FieldMap, FieldMappings, Geometry, NetCDFFileProperties, Point, RecordSet, Result, SpatialReference, and ValueTable).

String
options

Optional arguments depending on the object being created.

Object
返回值
数据类型说明
Object

返回的对象取决于第一个参数中指定的对象类型。

代码示例

CreateObject 示例

使用值表来保存联合工具的要素类名称和等级。

import arcpy

# Set the workspace. List all of the feature classes in the dataset.
arcpy.env.workspace = "c:/data/landbase.gdb/wetlands"
fcs = arcpy.ListFeatureClasses()

# Create the value table for the Analysis Union tool with 2 columns.
vtab = arcpy.CreateObject("valuetable", 2)

# Iterate through the list of feature classes.
for fc in fcs:
    # Update the value table with a rank of 2 for each record, except
    #   for BigBog
    if fc.lower() != "bigbog":
        vtab.addRow(fc + " 2")
    else:
        vtab.addRow(fc + " 1")

# Union the wetlands feature classes with the land use feature class
# to create a single feature class with all of the wetlands and land
# use data.
vtab.addRow("c:/data/landbase.gdb/land_use 2")
arcpy.Union_analysis(vtab, "c:/data/landbase.gdb/wetlands_use")

相关主题