Python noob here wondering if there's a direct way to return the name of a feature dataset for a feature class.
I know I can return the data source and extract the dataset name, but I figure there's got to be a way to directly return only the dataset name.
Along the same line, is there a way to check if a feature class belongs to a feature dataset?
Thanks in advance for any help.
Wes
arcpy.env.workspace= "your workspace" lstdataset = arcpy.ListDatasets() for item in lstdataset: print item lstfeatureclass=arcpy.ListFeatureClasses() for fc in lstfeatureclass: print fc
Thanks FLBB,
I looked into using list datasets/feature classes functions and they would work with some manipulation, which I know is normal. I was just hoping there was something like a describe function that would return the exact feature dataset name (if it existed) for the feature class.
I appreciate your reply.
Wes
import arcpy, os def GetFDS(FC): """ Returns the feature dataset for a feature class or feature layer FC. If the feature class is not within a feature dataset, returns None.""" # get the path to the feature class fcPath = arcpy.describe(FC).catalogPath # get the path to its container fcHome = os.path.dirname(fcPath) # is it a feature dataset?? if arcpy.describe(fcHome).dataType == "FeatureDataset": return fcHome else: return None