1

I am an experienced Arc user but new to python. I can not figure out where my syntax is wrong. I'm trying to use data driven pages to export to jpeg where the name of the file is the page name. It works fine through the usual export to pdf in File, Export, Pages dialog so I know that the data driven pages are set up correctly. The first line references the field name in the attribute table of the layer file that I have set to be the page name. The script works if I use the page number.

I'm using ArcGIS 10.2.2 for Desktop with a basic licence.

arcpy.mapping.ExportToJPEG(mxd, r"C:\Temp\Linn\Linn_KCH" + str(pageNum) + ".jpg")

This is the script I'm trying to run now.

field_name = "Page_Name"

mxd = arcpy.mapping.MapDocument("CURRENT")
for i in range(1, mxd.dataDrivenPages.pageCount + 1):
mxd.dataDrivenPages.currentPageID = i
row = mxd.dataDrivenPages.pageRow

pageName = mxd.dataDrivenPages.pageRow.Name

print row.getValue(field_name)
arcpy.mapping.ExportToJPEG(mxd, r"C:\Temp\Linn\Linn_KCH" + "." + row.getValue(field_name) + str(pageName) +".jpg") 
del mxd
PolyGeo
  • 65,136
  • 29
  • 109
  • 338
  • 1
    Looks like you need indentation underneath your "for i in range" statement. – alexGIS May 05 '16 at 18:10
  • Have a look at http://gis.stackexchange.com/questions/190966/export-arcgis-tiles-data-to-any-image-format/191623#191623 you can get field name from DDP property – FelixIP May 05 '16 at 19:38

0 Answers0