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

11-08-2018 10:19 PM
New Contributor III


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:
for layer in layers:
   layer.visible = True
   layout.exportToJPEG(r"C:\Users\kenta\Dropbox\Collaboration\CollaborationOki"+ "\\" + layer.name + ".JPEG")
   layer.visible = False

1 Reply
New Contributor II

Hi Kenta,

I know this is old but did you ever resolve this issue?


0 Kudos