Identify feature class within feature dataset

4799
13
10-01-2015 03:23 PM
MikeLouwrens
Occasional Contributor III

I have a list of feature class names I want to feed into a script, and one of the things I need the script to do is determine whether each feature class is held within a feature dataset (as then the script will treat the FC differently).

Using Describe I can identify feature classes and feature datasets, however I cannot determine whether a FC is within a FD.  I can list children of a FD, but not parent of FC.

Is there another way I can easily determine whether a specified FC is held in a FD?

The list of FCs is output from a third-party table, so doesn't reference feature datasets.  The FCs are contained in a database that has many feature datasets and hundreds of feature classes.  While I know I could Describe all the FDs in my database and compare the children to my list, I imagine this would take a long time, when my list only contains about 60 FDs and only about 15 of them are in FDs.

EDIT: If possible I would like to determine the name of the Feature Dataset, not just if there is one.  Data is in a SDE Geodatabase (SQL Server)

Thanks,
Mike.

Message was edited by: Mike Louwrens

Tags (2)
0 Kudos
13 Replies
DarrenWiens2
MVP Honored Contributor

You can list feature classes in your gdb. This won't go into feature datasets. If it's in the list, it isn't in a feature dataset. If it's not in the list, presumably it is in a feature dataset (or doesn't exist).

Please elaborate if this doesn't address your issue.

MikeLouwrens
Occasional Contributor III

Freddie Gibson:

You can list feature classes in your gdb. This won't go into feature datasets. If it's in the list, it isn't in a feature dataset. If it's not in the list, presumably it is in a feature dataset (or doesn't exist).

Please elaborate if this doesn't address your issue.

That might work, although not ideal.  I should probably have said in my original post that I'd like to know which FD the FC is in.

Cheers,

Mike.

0 Kudos
DarrenWiens2
MVP Honored Contributor

I'm unclear how you can describe a feature class and not know its path. The path tells you if it's in a feature dataset. Isn't this the case in SDE feature classes (obviously, I don't use SDE)?

MikeLouwrens
Occasional Contributor III

Darren Wiens:

I'm unclear how you can describe a feature class and not know its path. The path tells you if it's in a feature dataset. Isn't this the case in SDE feature classes (obviously, I don't use SDE)?

Hi Darren,

You don't need to specify the Feature Dataset in a path to a Feature Class (works the same way in a file/personal geodatabase as in SDE).  So as a result I can script things to happen to those feature classes without referring to the feature dataset at all.  However in this case I need to know which Feature Dataset contains each Feature Class, if any.

Cheers,

Mike.

0 Kudos
DarrenWiens2
MVP Honored Contributor

I stand corrected. I didn't realize you could refer to a feature class in a dataset without including the dataset in the path.

I think you're going to have to resort to something like arcpy.da.Walk() to find your feature class and the containing feature dataset, but I may be missing something else.

0 Kudos
FreddieGibson
Regular Contributor II

Could you provide a little more detail on how you're using the describe object against the feature classes? I would assume if you're to the point where you can describe the feature class you could also grab the path to the feature class on disk and check against it.

MikeLouwrens
Occasional Contributor III

Freddie Gibson:

Could you provide a little more detail on how you're using the describe object against the feature classes? I would assume if you're to the point where you can describe the feature class you could also grab the path to the feature class on disk and check against it.

Currently I'm not really using the describe other than testing ways to get the FD.  The data is in a SDE geodatabase so when I have tried using describe to get a path, no FD is ever listed (maybe I'm doing this wrong?)

Is there a describe option that would tell me the full path including the FD?

Cheers,

Mike.

0 Kudos
FreddieGibson
Regular Contributor II

Could you upload some of your code so I can get a better picture of what you're doing? For the most part whether you're working in an enterprise geodatabase or a local geodatabase (i.e. file or person) the workflow shouldn't differ. In order to use the describe object you'd need to have a reference to the dataset, whether it be the direct path to it or a layer that points to the data. That's why I'm a little confused on getting the path if you're able to get to this point. Hopefully by looking at your logic will help me fill in some of the blanks so that we can give you a solid answer for this.

MikeLouwrens
Occasional Contributor III

Hi Freddie,

sorry I currently don't really have any code - first thing I was trying to do was get Describe or something to identify the FD a FC was in, if any, so haven't actually written the script yet.  I can send you the few lines of different Describe options I have tried, but so far none of them have told me which FD the FC is in.  I'll be back in the office tomorrow, so will post that then.

Cheers,

MIke.

0 Kudos