ListFeatureClasses (arcpy)

摘要

列出工作空间中的要素类,受名称、要素类型和可选要素数据集的限制。此函数将返回一个 Python 列表。

讨论

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

语法

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

通配符可限制返回的结果。如果未指定任何通配符,则会返回所有值。

String
feature_type

The feature type to limit the results returned by the wild card argument. Valid feature types are:

  • AnnotationOnly annotation feature classes are returned.
  • ArcOnly arc (or line) feature classes are returned.
  • DimensionOnly dimension feature classes are returned.
  • EdgeOnly edge feature classes are returned.
  • JunctionOnly junction feature classes are returned.
  • Label Only label feature classes are returned.
  • LineOnly line (or arc) feature classes are returned.
  • MultipatchOnly multipatch feature classes are returned.
  • NodeOnly node feature classes are returned.
  • PointOnly point feature classes are returned.
  • PolygonOnly polygon feature classes are returned.
  • PolylineOnly line (or arc) feature classes are returned.
  • RegionOnly region feature classes are returned.
  • RouteOnly route feature classes are returned.
  • TicOnly tic feature classes are returned.
  • All All datasets in the workspace. This is the default value.

(默认值为 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

该函数返回包含了要素类名称的 Python 列表,并受可选通配符、要素类型和要素数据集参数的限制。

代码实例

ListFeatureClasses 示例

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

import arcpy
from arcpy import env
import os

# Set the workspace for the ListFeatureClass function
#
env.workspace = "c:/base"

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

# Copy shapefiles to a file geodatabase
#
for fc in fcList:
    arcpy.CopyFeatures_management(
        fc, os.path.join("c:/base/output.gdb", os.path.splitext(fc)[0]))

相关主题

9/15/2013