Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a very simple script, that loops through all the layers in a mxd and loops through the fields, and prints out the Alias Name for the field, but I am having some problems, it seems to be printing the field alias of the feature class (in SDE) not the value I have changed it to in the map document...

Here's the script

import os, arcpy

myMxdFolder = r"D:\Maps"
count = 0

for mxd in os.listdir(myMxdFolder):
    #print mxd
    if mxd.endswith(".mxd"):
        #if mxd.startswith("COMPASS") or mxd.startswith("COLGIS"):
        if mxd.startswith("COLGIS_City_Occupiers.mxd"):
            mxdoc = arcpy.mapping.MapDocument(myMxdFolder + os.sep + mxd)
            filePath =  mxdoc.filePath
            print filePath
            for lyr in arcpy.mapping.ListLayers(mxdoc):
                desc = arcpy.Describe(lyr)
                fields = desc.fields
                for field in fields:
                    print field.aliasName

The output is


but the Aliases in the map document i have set it to are:


and that is what I was expecting, have a missed a trick somewhere in the code?



share|improve this question
up vote 1 down vote accepted

Unfortunately, I think your answer can be found from this excerpt from this ESRI Help Document on Layer

Not all layer properties are accessible through the Layer object. There are many properties available in the ArcMap Layer Properties dialog box that are not exposed to the arcpy scripting environment (e.g., scale ranges, display properties, field aliases, symbology, and so on). The UpdateLayer function allows you to replace all layer properties available in ArcMap's Layer Properties dialog box using a layer (.lyr) file that contains the customizations.

It specifically references field aliases and the Layer Properties dialog.

This might be something worth submitting an idea to the ArcGIS Ideas site.

share|improve this answer
I saw that page but must have missed it. – MapMan Jun 20 '12 at 8:22

As Get Spatial said the Layer object does not seem able to get at the field aliases but if you use the Field class with ListFields or Describe then that looks like it does provide access to them.

share|improve this answer
This is the alias on the FC from SDE not from the map document. Thanks anyways. – MapMan Jun 20 '12 at 8:22
I forgot to read the documentation on types of field aliases at… before I responded. I'll be happy to vote for any ArcGIS Idea that asks for what you need here. – PolyGeo Jun 20 '12 at 9:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.