3

With help from people on this site, I have the following code to look for all of the element types in the geodatabase and put them into a report.

walk = arcpy.da.Walk(workspace, topdown=True)
    for dirpath, dirnames, filenames in walk:
        for filename in filenames:
            desc = arcpy.da.Describe(os.path.join(dirpath, filename))
            elements[desc['dataType']].append(desc)

report = ""

for element_type, element_list in elements.items():
    report += "{}:\n".format(element_type)
    for element_description in element_list:
        report += 
ntpath.basename("\t\t{}\n".format(element_description['featureClassType']))

Now I want to describe each of the element in detail. For example, if I want to include in the report what shape type (point/line/polygon/annotation) each feature class in the geodatabase is, I think I can use featureClassType, but I still do not understand how I can put it in to the code above.

5

Your code already describes the data. You now need to extract the shapeType from the Describe object. This is simply:

type = desc.shapeType

Why create the second set of for loops? Why not build your report as you're iterating through the workspace? Something like the following (untested) code:

walk = arcpy.da.Walk(workspace, topdown=True)
    for dirpath, dirnames, filenames in walk:
        for filename in filenames:
            desc = arcpy.da.Describe(os.path.join(dirpath, filename))
            featureClassType = desc.dataType
            shapetype = desc.shapeType
            #Do something here to write to your report
1

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.