ListFeatureClasses (arcpy)

Summary

Lists the feature classes in the workspace, limited by name, feature type, and optional feature dataset.

Discussion

The workspace environment must be set first before using several of the List functions, including ListDatasets, ListFeatureClasses, ListFiles, ListRasters, ListTables, and ListWorkspaces.

Syntax

ListFeatureClasses ({wild_card}, {feature_type}, {feature_dataset})
ParameterExplanationData Type
wild_card

The wild card limits the results returned. If no wild card is specified, all values are returned.

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.

(The default value is 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
Return Value
Data TypeExplanation
String

The list containing feature class names is returned from the function, limited by the optional wild card, feature type, and feature dataset arguments.

Code Sample

ListFeatureClasses example

Copy shapefiles to a geodatabase.

import os
import arcpy

# Set the workspace for the ListFeatureClass function
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.CopyFeatures_management(
        fc, os.path.join("c:/base/output.gdb",
                         os.path.splitext(fc)[0]))

Related Topics

6/21/2013