HOW TO
Data Driven Pages require the use of an index layer to determine the extent of the data frame for each page. The index layer can be any layer on the map used to define the extent, depending on the feature layers. The functionality of Data Driven pages can be enhanced further to enable export and use in a map document containing multiple data frames using the arcpy.mapping module.
This article provides steps to use and export Data Driven Pages with multiple data frames.
import os import arcpy from arcpy import mapping
mxd = arcpy.mapping.MapDocument("CURRENT")
masterFrame = arcpy.mapping.ListDataFrames(mxd)[0]
Frame2 = arcpy.mapping.ListDataFrames(mxd)[1]
Frame3 = arcpy.mapping.ListDataFrames(mxd)[2]
print mxd.dataDrivenPages.pageCount
for pageNum in range(1, mxd.dataDrivenPages.pageCount):
mxd.dataDrivenPages.currentPageID = pageNum + 1
Frame2.extent = masterFrame.extent
Frame3.extent = masterFrame.extent
mxd.dataDrivenPages.currentPageID = pageNum
print pageNum
OutF = os.path.join("<folder_location>" ,str(pageNum) + ".pdf" )
arcpy.mapping.ExportToPDF(mxd, OutF)
Note: Since the frame extent is set to copy the master extent, the data must be available in the same range on the map for the data frame to be visible.
The following shows the full code:
import os
import arcpy
from arcpy import mapping
mxd = arcpy.mapping.MapDocument("CURRENT")
masterFrame = arcpy.mapping.ListDataFrames(mxd)[0]
Frame2 = arcpy.mapping.ListDataFrames(mxd)[1]
Frame3 = arcpy.mapping.ListDataFrames(mxd)[2]
print mxd.dataDrivenPages.pageCount
for pageNum in range(1, mxd.dataDrivenPages.pageCount):
mxd.dataDrivenPages.currentPageID = pageNum + 1
Frame2.extent = masterFrame.extent
Frame3.extent = masterFrame.extent
mxd.dataDrivenPages.currentPageID = pageNum
print pageNum
OutF = os.path.join("C:/temp" ,str(pageNum) + ".pdf" )
arcpy.mapping.ExportToPDF(mxd, OutF)
Article ID: 000022852
Get help from ArcGIS experts
Start chatting now