3 Oct 2016

Data Driven Pages III: Printing and Exporting Tips

Submitted by geobug
Rating: 
GIS Dev

A successful map book is all fine and good, but, generally speaking, you're going to have to get it out of ArcMap and release it into the wild if it's going to be of much use to anyone.  So, in continuing our discussion on data driven pages (DDP), let's talk about printing and exporting.

If you have DDP enabled on your map document, you'll notice that you have some extra options in the File > Export menu, particularly if you want to export to PDF format. It's pretty easy to export selected pages, and you can export pages as a single document or as one document with many pages. It's pretty groovy. If you like PDFs.

Don't get me wrong; I'm all about a good vector export option. But at my office we regularly have to export DDP series with dozens or even hundreds of pages to PNG format, and if you want to do that through the file menu, you're exporting them one at a time.

And now for something completely different.
Here's where we get into Python and things get really fun. There are all kinds of things you can do with DDP if you're willing to rolling up your sleeves and muck around with a few lines of code.

If programming scares you a bit, or you feel like it's a little outside your range of skills, I totally understand. Consider taking a look at Python, though. It's a pretty straightforward language, it's easy to get your head around if you're a beginner at this, and it integrates with ArcGIS really well. Also, if you check out the documentation on the ESRI webpage for just about any tool in ArcToolbox, you'll find the code to implement the same tool in Python at the bottom of the page, so it's pretty easy to get yourself started.

The basic frame for using python with DDP always looks the same:

In the case above, we printed each page to the default printer.

Let's try something snazzier. This time we'll export each page to PNG and name the exported file after the page name in the DDP index we made.

You can run this code right from the python window in ArcMap (Geoprocessing > Python), or you can make a python tool in your toolbox so you can run it whenever you want. If you want to take a look at what an export script for ArcToolbox would look like, You can check out my Export DDP tool in my DDP Toolbox on GitHub.

Tip:
One thing that's worth thinking about if you're going to export your maps programmatically is how you're going to name them. Are you using the DDP page name to export your files? Are all those names appropriate for file names? If you have names in your series that include periods or slashes or other funny characters that your operating system might not appreciate, you may find your script failing with little explanation. Here's a simple way to fix that sort of thing:

Bug Alert:
You may be thinking that you're happy enough with PDF format, thanks very much and there's no reason for you to deal with this python stuff. Fair enough. But tell me if you've ever had this happen. You export your DDP set via the File > Export command and right after you finish, you realize that you made a typo. So you export them again, and your map document hangs for eternity over an endless abyss from which it will never return. You've just met Bug-00090284. This glitch crops when you export DDP with attribute-driven scales more than once from the same mxd in the same session. According to the documentation, this bug has been squashed in ArcGIS 10.4. My organization is still on 10.3 so I can neither confirm nor deny that claim. I'll tell you what though: export via python and it works flawless every time.


Other articles in this series: