By default, the ListFeatureClasses()
function will return all of the feature classes in a workspace. You will often want to restrict this list in some way. Three optional parameters can be passed into ListFeatureClasses()
to restrict the feature classes returned. All are optional. The first parameter is a wildcard used to restrict the returned list based on some combination of characters. Other parameters that can be used to restrict the list to include a datatype and a feature dataset.
The list of feature classes returned by the ListFeatureClasses()
function can be restricted through the use of a wildcard passed in as the first parameter. The wildcard is used to restrict the contents of your list based on a name. For example, you may want to return only a list of feature classes that start with the letter B
. To accomplish this, you use a combination of an asterisk with any number of characters. The following code example shows the use of a wildcard to restrict the contents of a list:
fcs = arcpy.ListFeatureClasses("B*")
In this recipe, you will learn how to restrict the list of feature classes returned through the use of a wildcard.
Follow these steps to learn how to restrict the list of feature classes returned by the ListFeatureClasses()
function through the use of a wildcard that is passed in as the first parameter:
c:ArcpyBookCh10ListFeatureClasses.py
script.C
:fcs = arcpy.ListFeatureClasses("C*")
Crimes2009 CityBoundaries CrimesBySchoolDistrict
18.220.254.4