I want to create a map series that exports two different sheets on one page. For example Page 1 would have sheet 1 & 2 and Page 2 would have sheet 3 & 4. I used to do this with python in ArcMap, but it seems the method to do this has changed. The way it is now only uses 1 frame.

Below is what I managed so far:

import time
import arcpy, os

aprx = arcpy.mp.ArcGISProject("CURRENT")
lyt = aprx.listLayouts("13 Dual Panel Route Map")[0]
m = aprx.listMaps("ROUTE MAP")[0]
ms = lyt.mapSeries
df1 = lyt.listElements("MAPFRAME_ELEMENT","Map Frame 01")[0]  #MAKE SURE LAYER NAME MATCHES DATAFRAME 
lyr = m.listLayers("MapIndex")[0]
index = lyr # my DDP index layer

# ColumnNumber          0      1      2
features = {row[0]:[row[1],row[2],row[3]] for row in arcpy.da.SearchCursor
     (index,['Id','SHAPE@','Scale','Name'])} # all index features(EDIT AS NECESSARY)
outpath = "A:\PROJECTS\WABASH VALLEY POWER\Enterprise South - Anson North\\05 PDF\\" #********CHANGE LINE HERE****************

#This part runs through the DDP, changing the pages and exporting them.
for pageNum in range(1,ms.pageCount,2):  
    ms.currentPageNumber = pageNum
    zoom = "Id = 1+1"
    df2.camera.setExtent(df2.getLayerExtent(lyr, True, True))
    ex_output = outpath + features[pageNum][2] + ".pdf" #EDIT AS NECESSARY
    #df1.scale = features[pageNum][1]
    #df2.extent = features[pageNum+1][0].extent
    #df2.scale = features[pageNum+1][1]
    print ("Exporting " + features[pageNum][2])
 #(out_pdf, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {embed_fonts}, {layers_attributes}, {georef_info}, {jpeg_compression_quality}, {clip_to_elements}, {output_as_image}#   
del aprx

I think the MapSeries class, and creating MapSeries objects using the Layout class, are useful for map series requirements that are relatively straightforward.

Whenever, I have more complex requirements, I instead use a SearchCursor to iterate the index layer, and zoom to the extent of each feature in it, before exporting a PDF file for each of those feature extents.

Once all pages have been created as PDF files, those can be appended together using the PDFDocument class.

The coding patterns above are things that I cover in the ArcPy for Python Developers using ArcGIS Pro eLearning course in a section titled Making Dynamic Maps and Map Series, which has lecture-led exercises on:

  • Using MapSeries class to export PDF from Map Series-enabled Layout; and
  • Using Index Layer and SearchCursor to emulate Map Series and export PDF.

Disclaimer: I am the author and presenter of the eLearning video course suggested above.

  • Thanks for your response. I've managed to get it to iterate through the index layer and zoom to the extent of each feature on map frame 1. The problem is I can't get the second map frame to iterate like the first frame. I've been playing with select by attribute and camera.getExtent to try the make the 2nd frame follow what the first frame is doing, but have been having no luck
    – John
    May 11 '20 at 4:23
  • I think you should start a new question for where you are stuck with that. Include a picture that shows what your output should look like. There'll be numerous variations on how you could do this. For example, if your second map on a page is an inset that changes for each page then you may want to give your index layer a field for "Map2Extent" and populate it.
    – PolyGeo
    May 11 '20 at 6:22
  • Ok thanks, I will try a new question!
    – John
    May 11 '20 at 6:53

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.