Select to view content in your preferred language

Multiple Page Layout with Logic

719
1
Jump to solution
07-27-2021 08:58 PM
TimothyMcKinney
Occasional Contributor

I have a dataset collected with Survey 123 and need to run a spatial map series for a filtered set of the data on a regular basis. The map series will be run on each unique entry but the number of pages will be dependent on the data and amount of pictures (attachments) for each entry. I am assuming this has to be done with arcpy.mp (don't see any other way to do multiple page layouts) but don't know and am looking for some guidance on where to start. Here is my initial thoughts. Any assessment regarding if I am on the right track would be great:

 

Page 1: will be similar for each unique entry but will change based on which attributes are present. My guess is I would need to create a layout based on each distinct first page.

 

Page 2-4: these pages will be reserved for imagery. Some entries will have 1 image some will have up to 6. All images will be attachments in the dataset. Based on the number of images I want different layouts to be used to best showcase the data.

 

The final goal is a PDF for each unique entry, the PDFs could be anywhere from 1 page to 5 pages based on the logic.

 

Given this my plan of attack is to create all the unique layouts with the dynamic data all setup. Then use arcpy.mp to analyze the entries and determine which layouts will be used and iterate through each entry and compile PDFs for each. Am I on the right track with this? If so I feel fairly comfortable creating the dynamic layouts but any help getting started with the arcpy.mp scripting would be helpful.

0 Kudos
1 Solution

Accepted Solutions
JeffBarrette
Esri Regular Contributor

Timothy,  thanks for posting this question.  I'm on the arcpy.mp and Layout teams and your inquiry forced me to look into a couple of things. 

First, my initial thoughts would be to automate with Python without using a MapSeries but picture attachments on a layout are only available with a map series.  So you would need a map series simply to iterate through your point locations - so you can iterate through your pictures for each point location.  The layout team is looking the possibility of making attachments available without a map series enabled.

Second - arcpy.mp does NOT allow you to change the attachment photo.  Picture.sourceImage returns the filter string but changing it an applying it back does not update the layout.  This is a bug and we will fix it.  A work-around for now is to use Python CIM access instead of the managed API for setting sourceImage.

p = arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts()[0]
lyt_cim = lyt.getDefinition('V2')
for elm in lyt_cim.elements:
  if elm.name == "Picture":
    pic.graphic.sourceURL = '<dyn filter="12"/>'
    lyt.setDefinition(lyt_cim)

Finally, you are on the right track and this logic will require python automation.  Take a look at the following sample.  It is very similar to your scenario but rather than there being 0-many pages or 0-many pictures on a page, it deals with the idea of there needed to be 0-many inset maps per layout.  This application persists all the settings in a database table and simply recreates each layout on demand.

https://www.arcgis.com/home/item.html?id=82b99b5593e54e57b740e3898fb14c5f

I hope this helps!

Jeff - arcpy.mp and Layout teams

View solution in original post

0 Kudos
1 Reply
JeffBarrette
Esri Regular Contributor

Timothy,  thanks for posting this question.  I'm on the arcpy.mp and Layout teams and your inquiry forced me to look into a couple of things. 

First, my initial thoughts would be to automate with Python without using a MapSeries but picture attachments on a layout are only available with a map series.  So you would need a map series simply to iterate through your point locations - so you can iterate through your pictures for each point location.  The layout team is looking the possibility of making attachments available without a map series enabled.

Second - arcpy.mp does NOT allow you to change the attachment photo.  Picture.sourceImage returns the filter string but changing it an applying it back does not update the layout.  This is a bug and we will fix it.  A work-around for now is to use Python CIM access instead of the managed API for setting sourceImage.

p = arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts()[0]
lyt_cim = lyt.getDefinition('V2')
for elm in lyt_cim.elements:
  if elm.name == "Picture":
    pic.graphic.sourceURL = '<dyn filter="12"/>'
    lyt.setDefinition(lyt_cim)

Finally, you are on the right track and this logic will require python automation.  Take a look at the following sample.  It is very similar to your scenario but rather than there being 0-many pages or 0-many pictures on a page, it deals with the idea of there needed to be 0-many inset maps per layout.  This application persists all the settings in a database table and simply recreates each layout on demand.

https://www.arcgis.com/home/item.html?id=82b99b5593e54e57b740e3898fb14c5f

I hope this helps!

Jeff - arcpy.mp and Layout teams

0 Kudos