6

I have generated about 90 maps through data driven pages(ArcGIS 10.0). I now want to export them as .jpg files in either landscape or portrait format. I tried python but it is not working, it worked to export as.png though.

Any suggestions?

closed as off-topic by PolyGeo Jun 14 '18 at 21:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    What part of the export from python did not work? Did it throw an error of some sort? If you still want to try python and jpg, then it might help to post the code if you think there is a problem with it. Providing more detail will help you get a better answer. How to ask questions – Get Spatial May 10 '12 at 16:22
  • I got it now. There was an error, fixed it. – mridul May 10 '12 at 16:46
  • 12
    What Get Spaial said :) ... Also, Post an answer to your own question mridul. Since you've sorted it out, others in the community may find your solution helpful with something similar they're trying to accomplish. – Dano May 10 '12 at 17:14
  • 2
    import arcpy mxd = arcpy.mapping.MapDocument(r"YourMapfilePath") print mxd.dataDrivenPages.getPageIDFromName("Index Layer name") for i in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = i row = mxd.dataDrivenPages.pageRow arcpy.mapping.ExportToJPEG(mxd, r"Output Path " + row.Index Layer Name + ".jpg") del mxd – mridul May 11 '12 at 19:51
  • 1
    You should take the comment containing your python code and paste it into an actual answer so that other people searching for a similar problem, will be able to find it. – Get Spatial Jun 3 '12 at 0:12
14

I'm simply reposting the code from above as an answer because I found it really useful but it took ages to find:

import_path = r"..."   # Path of .mxd
export_path = r"..."   # Path of output file
field_name = "Name" # Name of field used to sort DDP

mxd = arcpy.mapping.MapDocument(import_path) 
for i in range(1, mxd.dataDrivenPages.pageCount + 1):
   mxd.dataDrivenPages.currentPageID = i
   row = mxd.dataDrivenPages.pageRow
   print row.getValue(field_name)
   arcpy.mapping.ExportToJPEG(mxd, export_path + "." + row.getValue(field_name) + ".jpg") 
del mxd

Not the answer you're looking for? Browse other questions tagged or ask your own question.