ListFeatureClasses (arcpy)

Resumen

Lists the feature classes in the workspace, limited by name, feature type, and optional feature dataset. A Python List is returned from the function.

Debate

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

Sintaxis

ListFeatureClasses ({wild_card}, {feature_type}, {feature_dataset})
ParámetroExplicaciónTipo de datos
wild_card

El comodín limita los resultados que se obtienen. Si no se especifica ningún comodín, se obtienen todos los valores.

String
feature_type

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

  • Annotation —Only annotation feature classes are returned.
  • Arc —Only arc (or line) feature classes are returned.
  • Dimension —Only dimension feature classes are returned.
  • Edge —Only edge feature classes are returned.
  • Junction —Only junction feature classes are returned.
  • Label — Only label feature classes are returned.
  • Line —Only line (or arc) feature classes are returned.
  • Multipatch —Only multipatch feature classes are returned.
  • Node —Only node feature classes are returned.
  • Point —Only point feature classes are returned.
  • Polygon —Only polygon feature classes are returned.
  • Polyline —Only line (or arc) feature classes are returned.
  • Region —Only region feature classes are returned.
  • Route —Only route feature classes are returned.
  • Tic —Only tic feature classes are returned.
  • All — All datasets in the workspace. This is the default value.

(El valor predeterminado es 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
Valor de retorno
Tipo de datosExplicación
String

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

Ejemplo de código

ListFeatureClasses example

Copy shapefiles to a geodatabase.

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]))

Temas relacionados

9/11/2013