Skip to content

Instantly share code, notes, and snippets.

@cindygis
Last active August 29, 2015 14:16
Show Gist options
  • Save cindygis/4083d96f8d9c42a8a703 to your computer and use it in GitHub Desktop.
Save cindygis/4083d96f8d9c42a8a703 to your computer and use it in GitHub Desktop.
Exports data driven pages from a folder of map documents as JPEGs.
#
# @author Cindy Williams
# @date 23/08/2013
#
# Exports the data driven pages from a folder of
# map documents as JPEGs.
#
# For use as a script tool in an ArcGIS Toolbox.
#
import arcpy
import os
arcpy.env.overwriteOutput = True
#Input folder containing mxds
in_fld = arcpy.GetParameterAsText(0)
#Output folder for jpegs
out_fld = arcpy.GetParameterAsText(1)
#Loop over the folder containing the mxds
for root, dirs, filenames in os.walk(in_fld):
for f in filenames:
mxd = arcpy.mapping.MapDocument(os.path.join(in_fld,f))
# Loop over the data driven pages in the current map document
for i in range(1, mxd.dataDrivenPages.pageCount + 1):
mxd.dataDrivenPages.currentPageID = i
arcpy.AddMessage("Exporting {0} - {1}".format(f,i))
arcpy.mapping.ExportToJPEG(mxd,
os.path.join(out_fld,f.replace(".mxd","") + "_" +str(i) + ".jpg"),
resolution=300,
jpeg_quality=100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment