Select to view content in your preferred language

Python snippet to export a Map Series in Pro

2719
3
12-29-2017 09:44 AM
deleted-user-uXtLD1BYscf0
Deactivated User

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"
    arcpy.mapping.ExportToEMF(mxdchs,outEMF)
source:
Combining Data Driven Pages with Python and arcpy.mapping | ArcGIS Blog 
3 Replies
DanPatterson_Retired
MVP Emeritus

http://pro.arcgis.com/en/pro-app/arcpy/main/arcgis-pro-arcpy-reference.htm

arcpy.mapping is now arcpy.mp

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

0 Kudos
deleted-user-uXtLD1BYscf0
Deactivated User

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. 

https://community.esri.com/ideas/13607 

0 Kudos
SolanaFoo4
Regular Contributor

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 = arcpy.mp.ArcGISProject(relpath + "\\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