arcpy:获取特征 class 作为对象
arcpy: get feature class as object
如何根据地理数据库中的要素 class 在 python 中创建对象?我认为以下代码会创建一个 featureclass 对象?
featureclassobject = "C:/path/to/my/featureclass"
但这会创建一个字符串对象,对吧?所以我无法稍后将此对象传递给 arcpy 函数。
你说得对,它创建了一个字符串对象。但是,它是否适用于特定的 ArcPy 函数取决于函数——在 大多数 情况下,该工具只需要知道函数的路径 作为字符串(featureclassobject
是)。
帮助页面在这方面有点无用。 Buffer,例如,表示输入参数 in_features
需要是数据类型 "Feature Layer" —— 然而,它真正期望的是一个字符串,它描述了可以找到特征层的位置。
一个重要的例外是geometry objects:
In many geoprocessing workflows, you may need to run a specific operation using coordinate and geometry information but don't necessarily want to go through the process of creating a new (temporary) feature class, populating the feature class with cursors, using the feature class, then deleting the temporary feature class. Geometry objects can be used instead for both input and output to make geoprocessing easier.
但是,如果您已经在磁盘上获得了特征 class(或 shapefile),这比创建要使用的内存中几何对象要简单得多。
如何根据地理数据库中的要素 class 在 python 中创建对象?我认为以下代码会创建一个 featureclass 对象?
featureclassobject = "C:/path/to/my/featureclass"
但这会创建一个字符串对象,对吧?所以我无法稍后将此对象传递给 arcpy 函数。
你说得对,它创建了一个字符串对象。但是,它是否适用于特定的 ArcPy 函数取决于函数——在 大多数 情况下,该工具只需要知道函数的路径 作为字符串(featureclassobject
是)。
帮助页面在这方面有点无用。 Buffer,例如,表示输入参数 in_features
需要是数据类型 "Feature Layer" —— 然而,它真正期望的是一个字符串,它描述了可以找到特征层的位置。
一个重要的例外是geometry objects:
In many geoprocessing workflows, you may need to run a specific operation using coordinate and geometry information but don't necessarily want to go through the process of creating a new (temporary) feature class, populating the feature class with cursors, using the feature class, then deleting the temporary feature class. Geometry objects can be used instead for both input and output to make geoprocessing easier.
但是,如果您已经在磁盘上获得了特征 class(或 shapefile),这比创建要使用的内存中几何对象要简单得多。