I am using data driven pages and want to automatically export my layouts/extents to PNG. Since you have to use arcpy to export to PNG with data driven pages, I used following code, as explained here: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00sm00000008000000

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

The problem is that the quality is very bad when I export like this. If I export to PNG manually, and set for example 300 dpi, it is way better than exporting automatically.

Would you know a solution to export in better quality using arcpy and data driven pages in ArcMap?

3 Answers 3


The output resolution of the ExportToPNG tool is 96 dpi by default, but you can modify it, see the help page of the tool.

arcpy.mapping.ExportToPNG(mxd, r"C:\Temp\ParcelAtlas_Page" +str(pageNum) + ".png", resolution=300)

In the documentation it states you can specify the resolution in the method call (which defaults to 96), or there is the export width and height as follows:

arcpy.mapping.ExportToPNG(mxd, r"C:\Project\Output\ProjectDataFrame.png", df,

What is the python syntax for adding transparent background in PNG export?

I used transparent_color ='True' and I get an error as below:

TypeError: exportToPNG() got an unexpected keyword argument 'transparent_color'

Here the full code:

import arcpy, os, sys
aprx = arcpy.mp.ArcGISProject(r"D:\Working folder\ArcGIS Pro\THUMBNAILS\THUMBNAIL 800X800.aprx")
l = aprx.listLayouts("global map")[0]
ms = l.mapSeries
print (ms)
for pageNum in range(1, ms.pageCount + 1, 1):
        ms.currentPageNumber = pageNum
        region_name = str(ms.pageRow.WHO_REGION)
        country_name = str(ms.pageRow.ADM0_NAME)
        output_name = '{}_{}'.format(country_name,region_name)
        print('Exporting {}'.format(output_name))   
        l.exportToPNG((r"D:\Working folder\ArcGIS Pro\THUMBNAILS\OUTPUTS\thumbnails\{0}".format(output_name)+ ".png"),transparent_color= 'True',resolution=72)

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.