As a python noob, I'm attempting to create pdfs of layouts in which polygon features are symbolized with the same colors for classes, but the assignments change in each of 1,000 fields in the feature class. That is, I want to loop through each field (00000, 00001, 00002...), symbolize the categories (1-13) as set up in a .lyr file, change the map title to match the field name, print a pdf of the layout, & move to the next field to do it again.
What I have will change the map title & print the pdf with the title. The problem is every map is the same, except for the title. The polygons aren't given symbology according to the .lyr file, they're identical to the .lyr file.
I don't think it should matter, but the shapefile I'm symbolizing has 2692 rows. I need to display one field at a time, with each polygon (row) in the field shaded a specific color, depending on it's value, 1-13.
>>> import arcpy
... import os
... mxd = arcpy.mapping.MapDocument("CURRENT")
... df = arcpy.mapping.ListDataFrames(mxd, "*")
... featureclass = arcpy.mapping.ListLayers(mxd, "*", df)
... symbologyLyr = arcpy.mapping.Layer(r"\\path\Maps\SymbologyShp.lyr")
... field_names = [f.baseName for f in arcpy.ListFields(featureclass)]
... for f in field_names:
... if f.startswith("Map"):
... arcpy.mapping.UpdateLayer(df, featureclass, symbologyLyr, True)
... TextElement = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "MapTitleText")
... TextElement.text = f
... arcpy.mapping.ExportToPDF(mxd, r"\\path\outputPDF\Map_" + f)