Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this 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
11  
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
    
I used python code to parse out JPEGs generated from Data driven pages. this method is very useful with one wants to extract multiple maps at once in any format. –  mridul May 11 '12 at 19:48
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 Answer 1

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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