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
>>> 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'>:
Solved! Go to Solution.
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)[0] #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
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)[0] #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