0

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.

4
  • 2
    Please add a tag mentioning the python package that you're using. Based on context, I would guess ArcPy through ArcGIS Pro. Commented Oct 18, 2018 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()? Commented Oct 18, 2018 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/… Commented Oct 18, 2018 at 15:13
  • @smiller Yes_turning off the aliases did show that the second one was renamed "FLD_ZONE_1". Thanks! Commented Oct 18, 2018 at 15:20

1 Answer 1

3

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.

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.