AnsweredAssumed Answered

Data Driven Pages: Python code to include page index in output file name?

Question asked by bswindell on Nov 19, 2013
Latest reply on Nov 19, 2013 by bswindell
I have used the DDP toolbar to set up DDP where 'Reach' is the index layer (as in river reach).  Each of the 100 Reaches has an ID, stored in the attribute table.  I want the output JPG name to be Reach ID plus _reachmap.jpg, concatenated.  However, instead of Reach ID I am getting a number between 1 and 100.  I have tried replacing pageNum with various other things but I get the same results or an error.  How can I get DDP to 'see' the Reach ID instead of the generic 1 to 100?

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

Outcomes