Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Is there a way to alter the AliasName on a layer file only, and not the underlying shapefile or feature class? I have a few hundred layers that define joins between hundreds of tables with census data sitting in an MS Access database, and a shapefile with census tracts. I like to keep it this way to not have to store the feature geography for each of those data files.

Each layer file maps out hundreds of variables with intuitive names such as B19325_089. All said, there are several thousand. I would like to change the NameAlias property to have meaningful aliases/variable labels based on a lookup value, but, can it be done/defined in the layer file and not in the actual geography file, as all the layer files create the join to the same shapefile?

I got off to a decent start on feature classes in a file GDB using Mark Cederholm's and Matt Wilkie's suggestions, but am, as noted, curious about whether it is possible to have the alias definition reside in the layer files.

Initially, I thought it very simple and doable with the geoprocessor object as ESRI lists the AliasName property as read/write, but that appears to not be possible, and arcobjects to be necessary.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

It should be possible to cast your featurelayer to ITableFields, then loop through each ITableField.FieldInfo and set IFieldInfo.Alias. Last time I checked no error was raised when I assigned more than one field the same alias, so be careful.

Update: Field aliases can be confusing. There's an alias for fields that are stored in the database (IField.AliasName) which can be changed as shown in this thread. The IFieldInfo.Aliases are what you change when you go into the Fields tab on the Layer Properties dialog in ArcMap. I think those get initialized to whatever the IField.Alias is.

share|improve this answer
    
I will try this tomorrow, even though arcobjects is pretty new to me. Any clue why one can't just use the geoprocessor object, as esri's site suggests is possible with read/write permissions to the AliasName property? webhelp.esri.com/arcgisdesktop/9.3/… –  ako Jan 13 '11 at 6:34

Kirk,

This seems to work when you have a simple feature layer, however when the feature layer is joined the same code appears to run but actually has no effect. I am using ArcMap 9.1 and VB.Net. As I say this sub will work but only on the unjoined layer. On a joined layer the MessageBox returns false but looking in the Fields tab on properties shows all attributes still visible. This code is not what I actually want to do, I want a mix of visible and not and to set aliases but I have stripped it back for simplicity to try and get a solution. Any ideas?

Private Sub ConfigureRedlinesAttributes()

    Dim redlineFields As ILayerFields = CType(_redlinesLayer, ILayerFields)

    For i As Integer = 0 To redlineFields.FieldCount - 1

        Dim fieldInfoRed As IFieldInfo = redlineFields.FieldInfo(i)
        fieldInfoRed.Visible = False

    Next

    MessageBox.Show(redlineFields.FieldInfo(2).Visible.ToString())

End Sub

Update:

I have the answer to my own question. Subsequent setting of a DefinitionExpression on the FeatureLayer seemed to undo the attribute configuration. Swap code around to set DefinitionExpression first and it works as expected.

Cheers and sorry for any time wasted.

share|improve this answer

Your Answer

 
discard

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.