ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

ListFeatureClasses

  • Summary
  • Discussion
  • Syntax
  • Code sample

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 listed in the following table:

  • Annotation —Annotation feature classes
  • Arc —Arc (or polyline) feature classes
  • Dimension —Dimension feature classes
  • Edge —Edge feature classes
  • Junction —Junction feature classes
  • Label — Label feature classes
  • Line —Polyline (or arc) feature classes
  • Multipatch —Multipatch feature classes
  • Multipoint —Multipoint feature class
  • Node —Node feature classes
  • Point —Point feature classes
  • Polygon —Polygon feature classes
  • Polyline —Polyline (or arc) feature classes
  • Region —Region feature classes
  • Route —Route feature classes
  • Tic —Tic feature classes
  • All — All feature classes in the workspace. This is the default.

(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 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.CopyFeatures_management(
        fc, os.path.join("c:/base/output.gdb",
                         os.path.splitext(fc)[0]))
ListFeatureClasses example 1

List all feature classes in a geodatabase, including any in feature datasets.

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)

Related topics

  • Create lists of data
  • Walk

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2019 Esri. | Privacy | Legal