I've written an arcpy script tool to automate exporting a map series to a set of image files (one image file for each page of the map series).

Each image has the correct features displayed, for those layers that have a page query for the map series. So I know that changing the currentPageNumber of the map series is working, at least partially. It even progresses to the next page in ArcGIS Pro's table of Contents when showing the map series pages in the Contents page. The map title (which includes map-series-based elements) also updates correctly.

However, each image also has the same extent (the extent of the first page of the map series). There should be a different extent for each page (and for each image). The extent changes correctly when I change pages in ArcGIS Pro, but it does not change when running the tool. The extent in ArcGIS Pro's layout view also does not change when the tool runs (but as described above, it does change the page in the Contents pane, and changes the map page title).

The relevant portion of the tools script is as follows:

for pageNum in range(1, series.pageCount + 1):
    series.currentPageNumber = pageNum
    pageName = series.pageRow[0]
    userMsg("Exporting page {} of {} ({})...".format(pageNum, series.pageCount, pageName))
    filepath = os.path.join(outFolder, f"{filename} - {pageName}.{format.lower()}")
    if format = "JPEG":
        layout.exportToJPEG(filepath, resolution, jpeg_quality=jpegQuality)
        layout.exportToPNG(filepath, resolution)

How can I get this to show the correct extent for each exported image?


Adding a mapSeries refresh() immediately after each update to the currentPageNumer (ie, after each page change) fixes the problem MOST of the time (I've added this to the code above, commented out). But the problem still occurs randomly for approximately 3 of every 20 pages, even with the per-page refresh(). When using the refresh() (uncommented) it is random which pages have the problem. Without refresh() (commented out), ALL pages have the same extent.

1 Answer 1


I spoofed up the following script and embedded it into an atbx script tool. Then ran it with layout open and it ran as expected. I have ArcPro 3.1. Both jpeg and png exported with changing extents.

import arcpy, os, sys
def script_tool(param0 ):
    """Script code goes below"""
    relpath = r"c:\scratch"
    p = arcpy.mp.ArcGISProject("CURRENT")
    l = p.listLayouts()[0]
    if not l.mapSeries is None:
        ms = l.mapSeries
        if ms.enabled:
            for pageNum in range(1, ms.pageCount + 1):
                ms.currentPageNumber = pageNum
                print("Exporting {0}".format(ms.pageRow.name))
                pageName = ms.pageRow.name
                #l.exportToPNG(os.path.join(relpath, "Output", f"Ex2_{ms.pageRow.name}.png"))
                l.exportToJPEG(os.path.join(relpath, "Output", f"Ex2_{ms.pageRow.name}.png"), 150)
if __name__ == "__main__":
    param0 = arcpy.GetParameterAsText(0)

Could your erroneous extents be explained by multi-part features?

  • No, multipart features are not present here. The problem with the extent, is simply that it is the SAME extent for each page, irrespective of where the relevant feature is. Adding a mapSeries refresh() for each page change fixes the problem most of the time, but the problem still occurs randomly for approximately 3 of avery 20 pages, even with the per-page refresh(). When using the refresh() it is random which pages have the problem. Without refresh(), ALL pages have the same extent. See 'UPDATE' in OP. Oct 13, 2023 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.