Data Driven Pages - to PNG using ArcPy

1927
4
01-04-2017 12:41 PM
CamW
by
New Contributor II

Hello,

I am using ArcPy to export data driven pages to PNGs. I need the export to have a higher resolution then the default one when you export your map using ArcPy.

This is the script that I am using 

mxd = arcpy.mapping.MapDocument("CURRENT")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
mxd.dataDrivenPages.currentPageID = pageNum
pageName = str(mxd.dataDrivenPages.pageRow.New_ID)
arcpy.mapping.ExportToPNG(mxd, r"C:\Users\" + pageName + ".png")
del mxd

I want the resolution to be 200.

Where would I add this into the script?

0 Kudos
4 Replies
DarrenWiens2
MVP Honored Contributor

There is a resolution parameter: ExportToPNG—Help | ArcGIS Desktop 

CamW
by
New Contributor II

Thank you. Now where does it fit into the script?

0 Kudos
DarrenWiens2
MVP Honored Contributor

On each help page related to arcpy (e.g. arcpy functions, classes, or geoprocessing tools) the Python syntax for the "thing" is near the bottom. In this case, it says:

ExportToPNG (map_document, out_png, {data_frame}, {df_export_width}, {df_export_height}, {resolution}, {world_file}, {color_mode}, {background_color}, {transparent_color}, {interlaced})

I don't want to be too cryptic, but you need to do some of the work here.

FC_Basson
MVP Regular Contributor

Adding to Darren's comment, just change the export line to:

arcpy.mapping.ExportToPNG(mxd, r"C:\Users\" + pageName + ".png", resolution=200)