I just performed a union in my Python script between 2 features that both had a field attribute named "FLD_ZONE". My hope was that one of those attributes (for the second feature, I assumed) would be renamed "FLD_ZONE_1" in the union, but this was not the case.

Is there a way using Python to rename that second "FLD_ZONE" field name to "FLD_ZONE_1" or something different?

I know I can do that manually, but I'm not sure how that would work in a script.

  • 2
    Please add a tag mentioning the python package that you're using. Based on context, I would guess ArcPy through ArcGIS Pro.
    – Tom
    Oct 18 '18 at 15:05
  • 3
    What were your environment settings for retaining fully qualified field names? If you turn off the alias in your view, do you see any difference in the field names? What are the results of arcpy.ListFields()?
    – smiller
    Oct 18 '18 at 15:12
  • 2
    Assuming the output is in a GDB, you can change the fieldnames using AlterField: pro.arcgis.com/en/pro-app/tool-reference/data-management/…
    – smiller
    Oct 18 '18 at 15:13
  • @smiller Yes_turning off the aliases did show that the second one was renamed "FLD_ZONE_1". Thanks!
    – gwydion93
    Oct 18 '18 at 15:20

After turning off field aliases, OP confirmed that the second field was renamed "FLD_ZONE_1".

A few things that can be checked:

  1. Turn off field aliases and/or look at field properties
  2. in arcpy, use Listfields e.g.

    fieldlist = arcpy.ListFields()

    for field in fieldlist: print field.name

  3. Some functions retain the table / fc name. An environment setting can be adjusted for fully qualified field names. e.g. arcpy.env.qualifiedFieldNames = True

If you want to ensure different field names ahead of time and the inputs are in a GDB, you can use AlterField to modify the file names in arcpy.

  • Yes, this was the exact answer I was looking for. I used arcpy.ListFields to validate that was correct. Thanks for the assist.
    – gwydion93
    Oct 18 '18 at 15:36

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.