8

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?

8
  • 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 Commented May 10, 2012 at 16:22
  • I got it now. There was an error, fixed it.
    – mridul
    Commented May 10, 2012 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
    Commented May 10, 2012 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
    Commented May 11, 2012 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. Commented Jun 3, 2012 at 0:12

1 Answer 1

16

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.