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
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.