I have a MXD with a layer that has a field that has many values.

enter image description here

I need to export multiple layouts to PNG, applying a definition query to show the unique values for that layer.

i.e. Just show the features that share the same date, export, then move onto next date.

Data Driven Pages would be perfect, IF I wanted to export to PDF.

Looking for some guidance on how to script this with python or modelbuilder. I believe a combination of ExportToPNG and applying definition queries would be the way to go?

  • 1
  • Thats very useful, thanks. How do I get DDP to not create a page for each feature, but one page for all the fetures that share the same TimeOfDay_str?
    – jakc
    May 3, 2015 at 1:18
  • Are you wanting one map with a fixed extent where the features change? That might be more easily accomplished with the timeslider in this case than DDP. If you don't need the scale to be the same and want the extents to change, you'd need an index feature layer of polygons that covered the minimum bounding geometry of all features with the same attribute (ie select time one, use MBG on selection, select time two and repeat, combine all MBGs to a single file and use that as the DDP index). Screenshot examples of desired output in this case might help.
    – Chris W
    May 3, 2015 at 21:31
  • Correct. I also have time slider setup, but how would I export to Png and have control over the dpi and other options via time window? I will try the index layer with consistently sized polygons, the other approach I am contemplating is with Python and applying definition queries. Can update q with screens later
    – jakc
    May 3, 2015 at 22:24
  • 1
    I guess timeslider is limited to bmp and jpg, so that's out unless you're ok with converting after. But there is an arcpy method to exporting a time series of images. And as far as DDP goes, there's nothing that says you can't have the same index shape multiple times.
    – Chris W
    May 4, 2015 at 2:45

1 Answer 1


After exploring some options, since your data has a date/time field and you are already using a time slider, it seems the best way to go is using tools specifically aimed at exporting temporal series maps, rather than DDP or definition queries. The help files on the subject mention that you can use arcpy.mapping python scripts to produce time series output, specifically the DataFrameTime object along with ExportToPNG you originally mentioned. Using those resources and code examples you were able to come up with the following script to get what you wanted:

import arcpy, datetime
import os

mxd = arcpy.mapping.MapDocument(r"D:\Workings\PTV\GTFS_Vimeo.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
df.time.currentTime = df.time.startTime

while df.time.currentTime <= df.time.endTime:
    theTime = df.time.currentTime.strftime('%HH_%MM')
    print "theTime = " + theTime
    fileName = theTime + ".png"
    print "This is fileName: " + fileName
    arcpy.mapping.ExportToPNG(mxd, os.path.join(r"D:\Workings\PTV\Output", fileName))
    df.time.currentTime = df.time.currentTime + df.time.timeStepInterval
del mxd

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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