I'm using a python script to export a set of maps created with ArcMap's Data Driven Pages (DDP). Everything was working well until I added a new layer to the map - it automatically added to the legend, which I didn't want, so I removed it. Ever since then, however, the legend has been re-sizing at random during export.
It's not an overwrite issue (I'm removing all images from the target folder before running the script) and I've tried deleting and re-creating the legend, which has caused fewer of the maps to have re-sized legends, but there are still some. I'm not sure what to try next, or what caused this in the first place.
Here's my script (modified from Changing output name when exporting data driven pages to JPG?):
# Modify the directory to match your file locations import_path_Singles = r"C:\Users\Keegan\Desktop\14Feb2017_RVCAmapping\Arc_v10_3\RMP_Ag_SinglePlates.mxd" # The script will then generate output JPG files at a specified out-path: export_path = r"C:\Users\Keegan\Desktop\14Feb2017_RVCAmapping\Arc_v10_3\OutputJPGs" # Then specify a "sort" field field_name = "ASSESSMENT_ROLL_NUMBER" # Name of field used to sort DDP #field_name = "Assessment Roll Number" print field_name import arcpy mxd = arcpy.mapping.MapDocument(import_path_Singles) print mxd.dataDrivenPages.getPageIDFromName(field_name) for i in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = i row = mxd.dataDrivenPages.pageRow arcpy.mapping.ExportToJPEG(mxd, export_path + "\\" + row.getValue(field_name) + "SinglePlate.jpg") del mxd
The results can be seen in the image below - at left, good legend, at right, bad legend:
In Layout view, the legend looks like the one at left, and of the 21 maps I'm generating, some look like that one, and some look like the one at right.
Has anyone come across this before? Any idea what's going on here, and how to fix it?