import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum arcpy.mapping.ExportToJPEG(mxd, r"C:\output\\" + str(pageNum) + "_reachmap.jpg") del mxd
Solved! Go to Solution.
Using the pageRow property.
So something like arcpy.mapping.ExportToJPEG(mxd, r"C:\output\\" + str(mxd.dataDrivenPages.pageRow.Reach_ID) + "_reachmap.jpg")
import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") ddp = mxd.dataDrivenPages for pageNum in range(1, ddp.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum id_val = ddp.pageRow.getValue(ddp.pageNameField.name) arcpy.mapping.ExportToJPEG(mxd, r"C:\output\{0}_reachmap.jpg".format(id_val)) del mxd
Something like this should work if you are referring to your ddp index field value. If it isn't your index field then just insert the name of the field instead of ddp.pageNameField.nameimport arcpy mxd = arcpy.mapping.MapDocument("CURRENT") ddp = mxd.dataDrivenPages for pageNum in range(1, ddp.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum id_val = ddp.pageRow.getValue(ddp.pageNameField.name) arcpy.mapping.ExportToJPEG(mxd, r"C:\output\{0}_reachmap.jpg".format(id_val)) del mxd