Listing Feature Classes Multiple Feature type Using arcpy.ListFeatureClasses

3649
2
02-03-2012 08:54 AM
MikeMacRae
Occasional Contributor III
Hi everyone

is there a way to use arcpy.ListFeatureClasses() to filter multiple feature types. i.e. Only list the polygon and point feature types in the geaodatabase.
I've tried something like:

arcpy.ListFeatureClasses("*", ["Point", "Polygon"])


but this still returns all feature types (i.e. annotation and line FC's still get returned)

Is this possible?

Thanks,
Mike
Tags (2)
2 Replies
DarrenWiens2
MVP Honored Contributor
I don't know if it's possible to ask for two feature types at once. I'd just run through it twice and then append the results.

import arcpy

workspace = "H:/GIS_Data/TEMP.gdb"
arcpy.env.workspace = workspace # set workspace

pointfcs = arcpy.ListFeatureClasses('*', 'POINT') # get the points
polyfcs = arcpy.ListFeatureClasses('*', 'POLYGON') # get the polygons

pointfcs.extend(polyfcs) # smash together
MikeMacRae
Occasional Contributor III
Thanks for testing Darren. I just discovered a bit of a work-around using the arcpy.Describe() method. Something like:

import arcpy
from arcpy import env

env.workspace = "Z:\GIS\TEMP.gdb

fcList = arcpy.ListFeatureClasses()

for fc in fcList:
   desc = arcpy.Describe(fc)
   if desc.shapeType == "Polygon" or "Point":
       print fc