Created
November 1, 2019 18:26
-
-
Save andybell/02cd9588459e6a8f5ec1fb4be83ee388 to your computer and use it in GitHub Desktop.
Export ArcGIS Pro Layout Groups as PNGs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# export layer groups as pngs to create multiple views from a single layout | |
# run in arcgis pro python prompt, pngs will be created in the project folder using the name of the layer group | |
import arcpy | |
aprx = arcpy.mp.ArcGISProject("CURRENT") | |
m = aprx.listMaps()[0] # enter name of map if more than one | |
# get the list of the group layers in the current map | |
group_layer_list = [lyr for lyr in m.listLayers() if lyr.isGroupLayer] | |
# name of the layout to export | |
lyt = aprx.listLayouts()[0] # enter name of layout if more than one in project | |
# loop through each of the group layers and turn the visibility off | |
for group_layer in group_layer_list: | |
group_layer.visible = False | |
# now iterate through the groups and turn each on and export to a png | |
for group_layer in group_layer_list: | |
print(group_layer.name) | |
# turn group on | |
group_layer.visible = True | |
lyt.exportToPNG(f"{group_layer.name}.png", resolution=300) # export to png | |
# turn group off | |
group_layer.visible = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment