1

I have to re-project all Feature classes of a very large .sde. In order to iterate through the whole .sde I'm using arcpy.ListFeatureClasses. Getting all Feature classes into the Feature class list takes about 6 hours. As the Support window is open for a limited time only I would like to generate the Feature class list in advance and save it into a txt in order to be able to directly start the re-projection in the next Support window. I'm exporting and importing the list with pickle (Export and Import are working) but when I try to iterate through the imported pickle list, trying to apply arcpy.describe an error appears saying, that this Feature class does not exist.

How do I have to Export/Import the ListFeatureClasses Output in order to be able to reuse it later on with arcpy.describe?

I'm working with ArcGIS Desktop 10.6.

My Code in the first file to generate the fcList roughly looks like this:

In a Definition:

fcList = arcpy.ListFeatureClasses("%s.*" % (schema))            
return fcList

In the Main section:

with open(fcDictPath, "wb") as FCs:
     pickle.dump(fcList, FCs)

My Code in the file to perform the re-projection Looks like this:

with open(fcDictPath, "rb") as FCs:                 
 fcList = pickle.load(FCs)

for fc in fcList:
    dsc = arcpy.Describe(fcWithoutSchema)           
  • 1
    Because you dumped your list of feature classes to a pickle file, meaning they are no longer recognized as feature classes by Describe . I would run your describe with your listfeatureclasses., Once you've done your describe on features in fcList, you can do a pickle.dump or however you choose to store it – geodranic Jun 7 '18 at 16:10
4

ListFeatureClasses returns a list of strings; there is no special FeatureClass class that would be required by Describe. Instead, the issue is that you need to include the full path to the feature class and/or set the same workspace in both scripts.

So, if the first script is:

import arcpy, pickle
arcpy.env.workspace = r'\\Path\to\my\Database.sde'
fcList = arcpy.ListFeatureClasses('{}.*'.format('My_Schema'))
with open(r'C:\Path\to\my\Pickle.pickle', 'wb') as FCs:
     pickle.dump(fcList, FCs)

Then, the followup script should look like:

import os, pickle
arcpy.env.workspace = r'\\Path\to\my\Database.sde' # The workspace is the same as before.
with open(r'C:\Path\to\my\Pickle.pickle', "rb") as FCs:                 
 fcList = pickle.load(FCs)

for fc in fcList:
    dsc = arcpy.Describe(fcWithoutSchema)

Alternatively, your first script could create fcList by doing the following, which saves the full path to each feature class:

fcList = [os.path.join(arcpy.env.workspace, fc) for fc in arcpy.ListFeatureClasses('{}.*'.format('My_Schema'))]

Also, using Walk is a little more verbose but much faster than ListFeatureClasses:

root = r'\\Path\to\my\Database.sde'
fcList = list()
for d, fd, dss in arcpy.da.Walk(root):
    for ds in dss:
        if ds.startswith('My_Schema.'):
            fcList.append(os.path.join(d, ds))
  • Saving the full path to each Feature class did the trick. Thank you very much for your answer! – Sibir Jun 8 '18 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.