Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListFeatureClasses() glitch with SDE

I'm running ListFeatureClasses() on every Feature Dataset in my SDE using arcpy - the line goes something like this:

FDS = arcpy.ListFeatureDatasets()
for FD in FDS: 
  arcpy.env.workspace = FD
  print arcpy.ListFeatureClasses()

But for some of the feature datasets that I know (and can load data from), nothing is returned. Has anyone ever gotten this issue?

like image 524
jimf Avatar asked May 17 '26 03:05

jimf


1 Answers

Try this:

Set the workspace before the loop:

env.workspace = r"/path/to/geodatabase"

Set the feature dataset list:

datasets = arcpy.ListDatasets("*", "FeatureClass")

Set a list to contain the feature datasets:

fds = [fc for fc in datasets]

Loop through the feature datasets grabbing their feature classes:

for fd in fds: fc = arcpy.ListFeatureClasses("*", "ALL", fd) print "{}: {}".format(fd, fc)


Full snippet:

from arcpy import env
import arcpy

env.workspace = r"path/to/geodatabase"

datasets = arcpy.ListDatasets("*", "FeatureClass")

fds = [fc for fc in datasets]

for fd in fds:
    fc = arcpy.ListFeatureClasses("*", "ALL", fd)
    print "{}: {}".format(fd, fc)`

ListFeatureClasses (arcpy)

like image 150
Ken Avatar answered May 19 '26 00:05

Ken



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!