3

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?

4

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)
1

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,
                          df_export_width=1600,
                          df_export_height=1200)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.