Select to view content in your preferred language

List feature class alias...is this even possible?

4252
5
11-20-2013 10:43 AM
LinaDailide-Custodio
New Contributor
Is it possible to print a list of feature classes with their corresponding alias via Python?

If the aforementioned is possible, here???s another question???  My team is responsible for 400+ feature classes, some of which change on a frequent basis.  We have an Excel spreadsheet that lists the feature class (column 1) and the corresponding alias that we assign (column 2).  Could a Python script look at each feature class and ask the following questions for each one: ???Does the current feature class alias match the alias in the Excel spreadsheet (column 2)?  If yes, do nothing.  If no, change the alias to the one in the Excel spreadsheet (column 2).???

Currently we are opening the properties in ArcCatalog one-by-one to check the alias and/or hand jamming a new/replacement alias.... 

Thanks in advance!  We currently use ArcMap version 10 with a future upgrade to version 10.1
Tags (2)
0 Kudos
5 Replies
MathewCoyle
Honored Contributor
You can access the aliasName property through Describe. Without getting into ArcObjects I don't think you will be able to write to the aliasName property.

You can test to see if the alias matches the one in your record and flag that for modification, but automatically changing it would be more difficult.

Edit: My mistake. It seems there is a tool for that in 10.1. I don't think it is available in 10.0, however.

AlterAliasName
0 Kudos
ShaunWalbridge
Esri Regular Contributor
Right, AlterAliasName is new at 10.1 but is the right way of doing this for 10.1+.
0 Kudos
BryceGardner1
Emerging Contributor
While you wait for 10.1 if you still wanted to do this you could try a script similar to this.
import acrpy
arcpy.env.workspace = 'C:\\ENTER_YOUR_FILE_NAME_HERE'
#create variables for your two comparisons
feature_class = 'YOUR_FEATURE_CLASS_NAME'
table = 'YOUR_EXCEL_TABLE'

urows = arcpy.UpdateCursor(feature_class)
srows = arcpy.SearchCursor(table)

for srow in srows:
    table_alias = srow.COLUMN_NAME
    for urow in urows:
        feature_alias = urow.COLUMN_NAME
        if feature alias != table_alias:
            table_alias = feature_alias
            urows.UpdateRow(urow)

del srow, srows, urow, urows


I apologize for any wrong code, but I have only been coding for three months. I just wanted to try my hand and see if I could answer a question on here. It should work with a little bit of tweeking.

Regards,

Bryce
0 Kudos
MichaelVolz
Esteemed Contributor
Although someone did say that this task should be possible in v10.1, I would recommend going from v10.0 to v10.2 so you have less upgrades to perform.  My organization should be finished with this specific upgrade in a few weeks, but I did hear that sp1 for v10.2 should be out by the end of the year which should address some of the bugs that currently exist in v10.2.  From my experience, v10.2 is a glorified service pack to v10.1.
0 Kudos
LinaDailide-Custodio
New Contributor
Appreciate all the responses�?�

Tried using aliasName and it works for version 10, so that�??s great news!  (Also, thank you for pointing out that a feature class alias is the same thing as a table alias.)  Now the trick is to modify this simple script and have it run through an entire gdb while also listing the corresponding feature class�?�.  Then I can write a script where I can manually change feature class names, current alias and proposed alias in the code and run the script when changes are necessary.  This is an excellent start!  Many thanks!
0 Kudos