The arcpy Mapping Module is a way to custom code the ability to create a map series or map atlas. Map Series (in ArcMap the same functionality is Data Drive Pages) has come along way with automating map sheet production and may preclude the need to write any custom code. If Map Series doesn’t meet your need, then check out the arcpy mapping module.
The main requirements are:
- Pro Project stored on disk that includes at least one Map Tab and one Map Layout Tab
- Styled map layers in the Map tab
- A styled Map Layout tab
- Various map elements (text boxes, pictures, legends, map frames, north arrows, scale bars, etc) that include the map element “name.” (The map element name is the method to “find” and programmatically process changes for the map elements…mostly text elements).
The Mapping Module.zip file contains all of the files, data, and Jupyter notebooks that accompany the videos below. NOTE: When the mapping module.zip file is extracted, the folder will begin with “Chapter9…” that corresponds to the file/folder names mentioned in the videos and relate to the Python Primer Workbook (vol 2) Chapter 9. The Workbooks show Python 2.7x syntax. The videos and zip file contain Python 3.x script syntax and ArcGIS Pro references.
Prepping the Pro Project
Before getting started with the Mapping Module, it is a good time to review an existing Pro project that contain the Map tab, Map Layout tab, styled data layers and “named” map elements (primarily text elements). This video reviews the ProMapModule.aprx project file (found in the zip file above). This file is also referenced in the next video to review the Mapping Module Overview.
Mapping Module Overview
This video reviews many of the Mapping Module options that one will encounter when writing code for generating a Map Series. A series of 7 maps (PDFs) are produced, each with some difference from the previous map. The video will reference the Demo9b demo script. The numbering scheme refer to the Python Primer Workbooks (which uses Python 2.7x syntax, but have been rewritten with Python 3.x syntax). The zip file contains the Python 3.x syntax and Pro Project and data files.
Creating the Map Series Python Script
This video reviews the “stump” code provided to use as a starting point to write the Map Series Python script that autogenerates 13 PDF maps from 13 unique neighborhood boundaries found in the neighborhoods feature class. The MapBookProduction.aprx serves as the Pro Project file and contains the styled data and map elements. It is recommended the user open up the MapBookProduciton.aprx file and review the data and text elements before working on the Map Series script.
Use the Creating a Map Book Series Exercise document with the Jupyter notebook to complete the exercise.