Select to view content in your preferred language

Map export automation

4839
5
07-08-2014 09:59 AM
CoyPotts1
Deactivated User

Is it possible to create a script that would zoom to pre-designated bookmarks in the layout view and export a PDF of each bookmark?  I work on projects that have many different areas of data.  Once I'm done editing, I go to layout view, zoom to bookmarks, and print a PDF of each one.  It would be really nice if I could set up a script that would allow me to just click a button on a toolbar and it exports a PDF for me.

I am guessing that I would need to have a prompt for save folder location and PDF save name, but other than that the rest could be automatically set up.

Initially I just want to know if this is possible.  I know the code could be quite extensive, so I'm not asking anyone to write it for me.  I've done some research on it and I can't find a lot about it.  If it's possible, could someone guide me to a good resource for research on the topic, please? 

Thanks,

Coy Potts

0 Kudos
5 Replies
BondHarper
Frequent Contributor

Will data driven pages work for you? http://resources.arcgis.com/en/help/main/10.1/index.html#/What_are_Data_Driven_Pages/00s90000003m000...

Sounds like the default functionality might be all you need, but you can also customize as the data driven functionality can be accessed via Python as well (I've tweaked it to batch export JPGs to a specific job folder structure).

ChristianWells
Esri Regular Contributor

Since you already have the bookmarks set up, you can use the Mapping module to complete this. In this module, you would have access to a list of the bookmarks. Each bookmark object would have an extent which can then be applied to the data frame and the map document could be exported.

Sample workflow:

import arcpy





mxd = arcpy.mapping.MapDocument("CURRENT")


for bkmk in arcpy.mapping.ListBookmarks(mxd):


     ext = bkmk.extent


     df = arcpy.mapping.ListDataFrames(mxd)[0]


     df.extent = ext


     arcpy.mapping.ExportToPDF(mxd, r"C:\Temp\{0}".format(bkmk.name))

ListBookmarks:

ArcGIS Help 10.1

MapDocument:

ArcGIS Help 10.1

CoyPotts1
Deactivated User

Thanks to both of you guys, I am looking into each option now to see if either will better suit what I need.

Coy Potts

0 Kudos
DinaAlaiomid
New Contributor

I was wondering if you got Christian's code worked. That works but returns PDFs of Data View not the layout View. (sorry! I know your question is from a few years ago)

0 Kudos
ChristianWells
Esri Regular Contributor

Dina - I'm glad this script is still helpful for someone a couple of years later. In my script I didn't originally consider seeing the Layout view, however, this should be a simple item to address. What we'll need to do is set the mxd.activeView to "PAGE_LAYOUT" so the MXD shifts to the layout tab instead. Can you try this code instead?

import arcpy  
  
mxd = arcpy.mapping.MapDocument("CURRENT")
mxd.activeView = 'PAGE_LAYOUT'  
for bkmk in arcpy.mapping.ListBookmarks(mxd):  
     ext = bkmk.extent  
     df = arcpy.mapping.ListDataFrames(mxd)[0]  
     df.extent = ext  
     arcpy.mapping.ExportToPDF(mxd, r"C:\Temp\{0}".format(bkmk.name))  ‍‍‍‍‍‍‍‍‍

Edit: Here is the documentation I am referencing for the MapDocument Properties in ArcPy Mapping module.

MapDocument—Help | ArcGIS Desktop