Python snippet to export a Map Series in Pro

12-29-2017 09:44 AM
New Contributor III

Is there a Python 3 example to export a Map Series in Pro 2.0.1?

Below is what I've used in python 2.0 . ArcMap 10.5 - is there something equivalent for Pro that will allow me to export all pages in a map series using Python?

mxdchs = arcpy.mapping.MapDocument(r"[PATH TO]\GRS_CHS.mxd")
pageNameField = "GNumber"

for pageNum in range(1, mxdchs.dataDrivenPages.pageCount + 1):
    mxdchs.dataDrivenPages.currentPageID = pageNum
    pageName = mxdchs.dataDrivenPages.pageRow.getValue(pageNameField)
    outEMF = outputfolderCHS + pageName + ".emf"
Combining Data Driven Pages with Python and arcpy.mapping | ArcGIS Blog 
3 Replies
MVP Emeritus

arcpy.mapping is now

Too many things to decipher to provide a direct conversion, but you could get started in the arcpy documentation

0 Kudos
New Contributor III

I think this answers my question actually. Looks like you there is no Python way to export individual pages of a map series like there was in desktop..yet. 

0 Kudos
New Contributor III

Looks like they added this:

MapSeries example 3

The following script exports only the selected pages to a single, multipage PDF.

import arcpy, os, sys 
relpath = os.path.dirname(sys.argv[0])  
p = + "\\MapSeries\\US_States.aprx") 
l = p.listLayouts()[0] 
if not l.mapSeries is None:   
   ms = l.mapSeries   
   if ms.enabled:     
      ms = l.mapSeries     
      indexLyr = ms.indexLayer     
      arcpy.SelectLayerByAttribute_management(indexLyr, 'NEW_SELECTION', "SUB_REGION = 'New England'")     
      ms.exportToPDF(relpath + "\\Output\\Ex3_SelectedFeatures.pdf", 'SELECTED')

MapSeries—ArcPy | ArcGIS Desktop 

0 Kudos