<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Test if SDE feature class is part of a feature dataset? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/test-if-sde-feature-class-is-part-of-a-feature/m-p/11136#M922</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a way in ArcPy to test a featureclass in order to see if it is part of a featuredataset + get the name of the featuredataset?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 27 May 2011 20:02:27 GMT</pubDate>
    <dc:creator>mvisekru</dc:creator>
    <dc:date>2011-05-27T20:02:27Z</dc:date>
    <item>
      <title>Test if SDE feature class is part of a feature dataset?</title>
      <link>https://community.esri.com/t5/python-questions/test-if-sde-feature-class-is-part-of-a-feature/m-p/11136#M922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a way in ArcPy to test a featureclass in order to see if it is part of a featuredataset + get the name of the featuredataset?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 May 2011 20:02:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/test-if-sde-feature-class-is-part-of-a-feature/m-p/11136#M922</guid>
      <dc:creator>mvisekru</dc:creator>
      <dc:date>2011-05-27T20:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Test if SDE feature class is part of a feature dataset?</title>
      <link>https://community.esri.com/t5/python-questions/test-if-sde-feature-class-is-part-of-a-feature/m-p/11137#M923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not the most elegant solution which I have not tested, so hopefully someone has a better suggestion....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are calling this often in your code, you could create a dictionary of the geodatabase contents, and then run you tests against that&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
arcpy.env.workspace = "yourdegeodatabase.sde"

fcDict = {}

#loop through and fill dictionary
dsList = arcpy.ListDatasets()
for ds in dsList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList = arcpy.ListFeatureClasses("*","",ds)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcDict[fc] = ds

#test
myFC = arcpy.Describe("thefciwanttotest")
if myFC.name in fcDict:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print fcDict[myFC.name]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If it is a once only call in your script for one featureclass, this is a little more streamlined, again not tested.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
arcpy.env.workspace = "yourdegeodatabase.sde"

myFC = arcpy.Describe("thefciwanttotest")

#loop through
dsList = arcpy.ListDatasets()
for ds in dsList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList = arcpy.ListFeatureClasses(myFC.name,"",ds)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print ds
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:28:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/test-if-sde-feature-class-is-part-of-a-feature/m-p/11137#M923</guid>
      <dc:creator>AnthonyFarndon</dc:creator>
      <dc:date>2021-12-10T20:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Test if SDE feature class is part of a feature dataset?</title>
      <link>https://community.esri.com/t5/python-questions/test-if-sde-feature-class-is-part-of-a-feature/m-p/11138#M924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Is there a way in ArcPy to test a featureclass in order to see if it is part of a featuredataset + get the name of the featuredataset?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my suggestion:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os
def GetFDS(FC):
&amp;nbsp; """ Returns the feature dataset for a feature class
&amp;nbsp; or feature layer FC.

&amp;nbsp; If the feature class is not within a feature dataset,
&amp;nbsp; returns None."""
&amp;nbsp; # get the path to the feature class
&amp;nbsp; fcPath = arcpy.describe(FC).catalogPath
&amp;nbsp; # get the path to its container
&amp;nbsp; fcHome = os.path.dirname(fcPath)
&amp;nbsp; # is it a feature dataset??
&amp;nbsp; if arcpy.describe(fcHome).dataType == "FeatureDataset":
&amp;nbsp;&amp;nbsp;&amp;nbsp; return fcHome
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return None
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:29:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/test-if-sde-feature-class-is-part-of-a-feature/m-p/11138#M924</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-10T20:29:01Z</dc:date>
    </item>
  </channel>
</rss>

