ListFeatureClasses

摘要

可返回当前工作空间中受名称、要素类型和可选要素数据集限制的要素类的列表。

说明

必须先设置工作空间环境,然后才能使用多个列表函数,包括 ListDatasetsListFeatureClassesListFilesListRastersListTablesListWorkspaces

语法

ListFeatureClasses ({wild_card}, {feature_type}, {feature_dataset})
参数说明数据类型
wild_card

限制返回的结果。如果未指定某一值,则返回所有值。通配符不区分大小写。

符号说明示例

*

表示零个或多个字符。

Te* 可找到田纳西州和德克萨斯州。

String
feature_type

The feature type that will limit the results. Valid feature types are listed in the following table:

  • AnnotationAnnotation feature classes
  • ArcArc (or polyline) feature classes
  • DimensionDimension feature classes
  • EdgeEdge feature classes
  • JunctionJunction feature classes
  • Label Label feature classes
  • LinePolyline (or arc) feature classes
  • MultipatchMultipatch feature classes
  • MultipointMultipoint feature class
  • NodeNode feature classes
  • PointPoint feature classes
  • PolygonPolygon feature classes
  • PolylinePolyline (or arc) feature classes
  • RegionRegion feature classes
  • RouteRoute feature classes
  • TicTic feature classes
  • All All feature classes in the workspace. This is the default.

(默认值为 All)

String
feature_dataset

Limits the feature classes returned to the feature dataset, if specified. If blank, only stand-alone feature classes will be returned in the workspace.

String
返回值
数据类型说明
String

该函数返回包含要素类名称的列表,该列表受可选的 wild_cardfeature_typefeature_dataset 参数的限制。

代码示例

ListFeatureClasses 示例

将 shapefile 复制到地理数据库中。

import os
import arcpy

# Set the workspace for ListFeatureClasses
arcpy.env.workspace = "c:/base"

# Use the ListFeatureClasses function to return a list of
#  shapefiles.
featureclasses = arcpy.ListFeatureClasses()

# Copy shapefiles to a file geodatabase
for fc in featureclasses:
    arcpy.management.CopyFeatures(
        fc, os.path.join("c:/base/output.gdb",
                         os.path.splitext(fc)[0]))
ListFeatureClasses 示例 1

列出地理数据库中所有的要素类,包括要素数据集中的所有要素类。

import arcpy
import os

arcpy.env.workspace = "c:/base/gdb.gdb"

datasets = arcpy.ListDatasets(feature_type='feature')
datasets = [''] + datasets if datasets is not None else []

for ds in datasets:
    for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
        path = os.path.join(arcpy.env.workspace, ds, fc)
        print(path)

相关主题