1

I'm appending two sepearte shapefiles into one feature class with different subtypes. Is there a way to only calculate fields from a certain subtype?

4

To answer your main question of if it is possible to calculate fields from a certain subtype; there are two main functions that could be used to interrogate what field type a column is in a feature class. arcpy.Describe used on a field object or arcpy.ListFields used on a feature class (see ESRI documentation here about field object).

One way you could then solve your problem would be to create a function like this and return a list of field names of that type:

    def GetFieldNamesOfType(fc, fieldType):
        returnFieldNames = []
        fields = arcpy.ListFields(fc)
        for field in fields:
            if field.type == fieldType:
                returnFieldNames.append(field.name)
        return returnFieldNames

If I understand the end goal of what you want to accomplish correctly… The returning list of field names could be used to limit a Search Cursor (as the fields argument) to get the values from each feature class matching the field type of interest. These values could then in turn be used in an Insert Cursor for the new merged feature class.

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.