Renaming of Legend Name instead of Layer Name

196
0
07-27-2022 08:58 PM
sahus
by
New Contributor II

I would like to change the legend name instead of the field name. I would like to reference the legend name below the field name in this case. 

sahus_0-1658980437841.png

In this case, I would like to rename the yellow highlighted portion. I have a whole series of layers I have to make a change to, so a python script would be useful.

Currently, I can only change the field name (above the highlighted portion), I have used this function:

I created a few lists, and then placed these lists in a list called RenamedStats.

Travel Stats = [[Aussie, Australia],[Belg, Belgium]]

....

RenamedStats = [Travel Stats, Oil Stats]

for lyr in map.listLayers():
      for group in RenamedStats:
           for i in group:
                 if str(lyr.name) == i[1]:
                    lyr.name = i[0]
                    print(f"Layer renamed to: {lyr.name}")

 

Update: I think I am referring to what is being called as field aliases in this case.

0 Replies