Select to view content in your preferred language

Describe() breaks on coverages

530
4
Jump to solution
01-18-2023 08:19 AM
AlfredBaldenweck
MVP Regular Contributor

Hi all, 

I am running into something really weird and I was wondering if anyone could tell me what's happening here.

I have a coverage that I'm trying to describe.

AlfredBaldenweck_0-1674057934991.png

 

 

 fdList = arcpy.ListDatasets()

# Print feature classes in Datasets   
    if fdList:
        for fd in fdList:
            print(fd)
            desc= (arcpy.da.Describe(fd))
            #print(desc)
            print(desc['catalogPath'], desc['datasetType'])
            if desc['datasetType'] == "FeatureDataset":
                print("true")

''' Yields:'''
# T:\...\nhd FeatureDataset
# true
# T:\...\nhdpt FeatureDataset
# true
# T:\...\nhdduu FeatureDataset
# true

 

 

However, if I try to do anything with it, I get an error:

 

 

    if fdList:
        for fd in fdList:
            #print(fd)
            desc= (arcpy.da.Describe(fd))
            #print(desc)
            print(desc['catalogPath'], desc['datasetType'])
            if desc['datasetType'] == "FeatureDataset":
                print("true")
                
            if desc['datasetType'] == "FeatureDataset":
                arcpy.env.workspace = os.path.join(dirP, fd)
                fdFCList =arcpy.ListFeatureClasses()
                if fdFCList:
                    for fc in fdFCList:
                        fList.append([os.path.join(dirP, fd, fc)])
'''Yields:''
# T:\...\nhd FeatureDataset
# true
# ---------------------------------------------------------------------------
# ValueError                                Traceback (most recent call last)
Line 4:    desc= (arcpy.da.Describe(fd))

ValueError: Object: Error in accessing describe

 

 

 In short, it'll do the first one or two feature datasets, then it'll break somehow.

Sometimes it does just the first, sometimes it does the first two.

Has anyone encountered anything like this before?

Thanks!

 

 

Edit: It looks like it has to do with setting the environment. How do I fix this? It worked fine for feature datasets in GDBs.

0 Kudos
1 Solution

Accepted Solutions
AlfredBaldenweck
MVP Regular Contributor

I ended up just resetting the environment to the original directory after appending all the feature classes.

View solution in original post

0 Kudos
4 Replies
AlfredBaldenweck
MVP Regular Contributor

I ended up just resetting the environment to the original directory after appending all the feature classes.

0 Kudos
dongheekim
New Contributor II

Hi @AlfredBaldenweck ,

I encountered the same error message with you in my Python script that previously worked fine with the same code. Could you explain how to reset the environment within the script?

Thanks,

Donghee

 

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Yeah of course. It's just doing this:

arcpy.env.workspace = 'path to your desired geodatabase'

 Environment settings in Python—ArcGIS Pro | Documentation

dongheekim
New Contributor II

Thank you for sharing the code.

I realized the error message was related to the arcpy environment from your solution. However, I also encountered an error message about the kernel in the code below:

arcpy.management.CreateFileGDB()

In my case, I was able to resolve the same error message by downgrading ArcGIS Pro's version from 3.2 to 3.1.

Appreciate your assistance!

0 Kudos