I have a layer with forest districts and I need to generate map of every district. That is quite uncomplicated, however maps need to have a legend, where the symbology is the same for every district, but the name changes. Few solutions came to my mind, but they have certain disadvantages:

  • creating layers for every district and updating symbology, but that seems too be overly complicating task

  • I could put a text element on the legend and just update its content with name, but that is "not elegant" - eventual moving legend will mess up the layout

  • I thought, as I use Definition Query anyway, I could use symbology type Single Symbol and just update description with district name, but I couldn`t find entry for this feature.

Here is a sample for second idea:

with arcpy.da.SearchCursor("districts", ["district_name", "SHAPE@"]) as cursor: 
    for row in cursor:
        for TextElement in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
            if TextElement.name == "forest_district":
                TextElement.text = row[0]

It would be best if I could treat single symbol description in a similar manner as TextElement, but as I said I couldn't find any entry for this.

So, I would like to know if anyone knows how to edit description in single symbol symbology type with Python? Or maybe someone has better idea for solving my task?

EDIT: I finally put TextElement next to symbol on legend and used the loop from example to assign district names. The good thing is that text can be changed even after grouping legend with TextElement, so there is no mess after moving legend. It looks good, nevertheless I am not very proud of this solution.

  • For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question. There is an edit button beneath your question which will enable you to do that and a {} button that enables you to format any highlighted code nicely.
    – PolyGeo
    Dec 28, 2016 at 10:37
  • @PolyGeo how do you want me to show my code concerning this question? Should I show code for cases that are not suitable for me? I find my problem statement rather clear, however I am not able to provide code for something that I don`t even know if can be coded.
    – Kubson
    Dec 28, 2016 at 10:48
  • Yes - show code snippets that illustrate what you have tried and why they are unsuitable for you. Q&As here are give and take, The code you show may be useful to someone else. Asking for code without giving some never seems like a good trade for anyone but the asker. No need to show code for all three ideas you have; just show the one that gets closest to achieving what you are trying to do.
    – PolyGeo
    Dec 28, 2016 at 10:51
  • Ok I added most significant in my opinion code part.
    – Kubson
    Dec 28, 2016 at 11:50

1 Answer 1


Have you tried to create a mapbook with datadriven.


But you dont have to create tiles, because you have you district boundary. After creation of mapbook you can display your district name under (insert/Dynamic text/datadriven page attribute). Than when export to PDF chose pages than "All Pages".

  • That is good idea, but not for my case. I need these maps in quite specific format, that I cannot change and also I need to export them in PNG.
    – Kubson
    Dec 28, 2016 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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