Good morning all
I'm trying to pull together some code to export the data view (not the page layout view) to PNG. The issue I'm having is that when I use the df variable in the ExportToPNG function, I am getting an Assertion Error. If I substitute df for "PAGE_LAYOUT" the script runs, but the output is not what I'm looking for.
Any ideas how to solve this?
This is what I've got so far:
Edit: I didn't actually get this above code to run, but I got similar code running thru the Python window in ArcMap.
I'm trying to pull together some code to export the data view (not the page layout view) to PNG. The issue I'm having is that when I use the df variable in the ExportToPNG function, I am getting an Assertion Error. If I substitute df for "PAGE_LAYOUT" the script runs, but the output is not what I'm looking for.
Any ideas how to solve this?
This is what I've got so far:
Code:
import arcpy
import os
from arcpy import env
from time import localtime, strftime
# Set workspace
arcpy.env.workspace = r'd:\gis\aerialtracking\output'
ws = arcpy.env.workspace
if str(os.path.exists(ws)) == "False":
os.makedirs(ws)
# Set time variable and print output variable
printtime = strftime("%Y%m%d_%H%M", localtime())
print printtime
pngname = "mapexport_" + printtime + ".png"
print pngname
# Set mxd
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)
#Export PNG
arcpy.mapping.ExportToPNG(mxd, pngname, df, df_export_width = 1600, df_export_height = 1200, world_file = True)
#delete variables
del df, ws, printtime, pngname, mxd
Code:
>>> arcpy.mapping.ExportToPNG(mxd, r'D:\gis\aerialtracking\output\test.png', "PAGE_LAYOUT")
>>> arcpy.mapping.ExportToPNG(mxd, r'D:\gis\aerialtracking\output\test.png', df)
Runtime error <type 'exceptions.AssertionError'>: