leilahb

problem with python code exporting to png with time enabled layer

Discussion created by leilahb on Apr 3, 2012
Latest reply on Apr 10, 2012 by mzcoyle
Hello
I'm using the ESRI sample code to export a mxd to a series of .PNG files. I set all parameters e.g. Startime, endtime.. etc. When I use the time slider, the changes on map appear correctly (different maps for different time-steps), But when I export it using the python code it create a series of PGN of the same map (it seems like pgns are several copies of the original map).

I don't know why it works in ArcMap but not when exporting. Any help would be greatly appreciated.

Thank you


import arcpy, datetime
mxd = arcpy.mapping.MapDocument(r"D:\project3.mxd")
df = arcpy.mapping.ListDataFrames(mxd,"layers")[0]
df.time.resetTimeExtent()
df.time.timeWindowUnits = "days"
df.time.timeWindow = 0
df.time.currentTime = datetime.datetime(1905, 06, 26)
endTime = datetime.datetime(1905, 07, 4)
interval = datetime.timedelta (days=2)
while df.time.currentTime <= endTime:
    fileName = str(df.time.currentTime).split(" ")[0] + ".png"
    arcpy.mapping.ExportToPNG(mxd, r"D:\\" + fileName,df)
    df.time.currentTime = df.time.currentTime + interval
    print fileName
del mxd

Outcomes