AnsweredAssumed Answered

Legend not updated in exported layout (arcpy.mp exporting multiple maps)

Question asked by kenta215ok0 on Nov 8, 2018

Hi, 

I'm using arcpy.mp to export multiple layers at once, but having a trouble that legend is not updated.

Each layer is successfully exported as separate JPEG file by the code below. However, the legend attached to each exported output is all the same (legend of the first layer). 

I usually run my script as standalone from Jupyter notebook. When I run the code below in python window within ArcGIS pro, legend was successfully updated in each exported output.

If anybody has any idea on why it cannot be done by standalone, I would really appreciate it.

ArcGIS Pro 2.2

 

# This is the code I ran
aprx = arcpy.mp.ArcGISProject(r"C:\Users\kenta\Documents\ArcGIS\Projects\CoHRE_Collaboration\CoHRE_Collaboration.aprx")
maps = aprx.listMaps("Oki")[0]
layers = maps.listLayers("mean*")
layout = aprx.listLayouts("Oki_layout")[0]

for layer in layers:
   layer.visible=False
for layer in layers:
   layer.visible = True
   layout.exportToJPEG(r"C:\Users\kenta\Dropbox\Collaboration\CollaborationOki"+ "\\" + layer.name + ".JPEG")
   layer.visible = False

Outcomes