Select to view content in your preferred language

Trouble iterating through a table, setting map frame extent to row, and importing a PDF

523
2
Jump to solution
07-16-2019 03:39 PM
JakeJohnson
Emerging Contributor

Hi,

I'm trying to take a table of polygons that split my physical area of interest into 700 chunks. I'm tasked with taking each section and putting it into a layout for making backup paper maps. The layout is no problem, it's the automating of showing the selected section in the map frame that is not working for some reason. I'm new to ArcPy but my research so far seems to point to arcp.da.SearchCursor as the class to carry this out. Like so:

import arcpy

aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("Maps*")[0]
lyt = aprx.listLayouts("Layout*")[0]
lyr = m.listLayers("Layer*")[0]
mf = lyt.listElements("mapframe_element", "MapFrame*")[0]
fc = "Sections"
field = "OBJECTID"

with arcpy.da.SearchCursor(fc, field) as cursor:
   for row in cursor:
      mf.camera.setExtent(mf.getLayerExtent(lyr/row?, True, False)
      # and then here I would save to PDF
del row, cursor‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Judging by my code so far, I think I'm trying to zoom into the wrong thing and that something else is missing. I'm using ArcGIS Pro 2.4.0. Appreciate any assistance, thanks!

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Luke_Pinner
MVP Regular Contributor

Have you considered a Map Series (what was known as Data Driven Pages in Desktop)?

Map series—Layouts | ArcGIS Desktop 

View solution in original post

2 Replies
Luke_Pinner
MVP Regular Contributor

Have you considered a Map Series (what was known as Data Driven Pages in Desktop)?

Map series—Layouts | ArcGIS Desktop 

JakeJohnson
Emerging Contributor

I never even considered ESRI had a built-in feature for this exact purpose. It works exactly the way I need and is way easier. Thank you!

0 Kudos