1

Within a python toolbox, I'm trying to retrieve subtypes from a feature layer in ArcGIS Pro using arcpy.da.ListSubtypes(). The feature layer is a hosted feature service on ArcGIS Online. Rather then returning a dictionary populated with all subtypes, the code below returns a single entry in the subtypes dictionary that looks like default values for a feature class that does not have subtypes defined. In addition, the SubtypeField property is empty.

subtypes = arcpy.da.ListSubtypes(layerSelected)
for stcode, stdict in list(subtypes.items()):
    for stkey in list(stdict.keys()):
        if stkey == "SubtypeField":
            subtypeFieldName = stdict[stkey]  

The single entry in the subtypes dictionary has a key = 0, and a value of:

        {'Default': True, 
         'Name': 'L14Barriers', 
         'FieldValues': {'OBJECTID': (None, None), 'GlobalID': (None, None), 
                         'Subtype': (None, None), 'Site': (None, None), 
                         'Comments': (None, None), 'Material': (None, None), 
                         'Authorized': (None, None), 'InCompliance': (None, None), 
                         'FeatureStatus': (None, None), 
                         'AdjacentParcel': (None, None), 
                         'OldPermitID': (None, None), 'EncroachmentStatus': (None, None), 
                         'Shape__Length': (None, None), 'Shape': (None, None)},  
         'SubtypeField': ''
         }

Notice that the SubtypeField property is an empty string. This works just fine if you run it against a layer that is sourced in a geodatabase. It returns the subtypes, fields, and references to domains for each subtype. However, against a feature service layer arcpy.da.ListSubtypes() does not recognize the subtypes. Is there another method for acquiring subtypes from a feature service?

Your Answer

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

Browse other questions tagged or ask your own question.