<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Export multiple layers individually to image, same extent, arcgis pro in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/export-multiple-layers-individually-to-image-same/m-p/1388731#M79522</link>
    <description>&lt;P&gt;Great &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/770793"&gt;@AA25&lt;/a&gt;&amp;nbsp;, you found it! I did some tests on my end, and was able to export separate images. (Extent is set through layout itself, I was unable to set it through code). Hope this helps as well.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

# Set the workspace
arcpy.env.workspace = r"C:\Users\geete\Downloads\exported"

# Set the map document
aprx = arcpy.mp.ArcGISProject("CURRENT")
map = aprx.listMaps("Map")[0]  

# Get the extent of the map
#map_extent = map.defaultCamera.getExtent()

# Create a new layout for exporting
layout = aprx.listLayouts()[0] 

# Iterate through each layer in the map
for layer in map.listLayers():
    # Turn off all layers except the current one
    for lyr in map.listLayers():
        if lyr == layer:
            lyr.visible = True
        else:
            lyr.visible = False

    # Set the extent of the layout map frame
    layout_map_frame = layout.listElements('MAPFRAME_ELEMENT')[0]

    # Define output PNG filename
    output_png = os.path.join(r"C:\Users\geete\Downloads\exported", f"{layer.name}.png")

    # Export the layout to PNG
    layout.exportToPNG(output_png, resolution=60)

    # Reset visibility of all layers
    for lyr in map.listLayers():
        lyr.visible = True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Feb 2024 12:50:29 GMT</pubDate>
    <dc:creator>GeeteshSingh07</dc:creator>
    <dc:date>2024-02-29T12:50:29Z</dc:date>
    <item>
      <title>Export multiple layers individually to image, same extent, arcgis pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/export-multiple-layers-individually-to-image-same/m-p/1388604#M79518</link>
      <description>&lt;P&gt;In arcgis pro, I have a 5 polygons layers.&lt;/P&gt;&lt;P&gt;I'd like to export an image of each layer alone (5 images), without the other 4 layers being visible.&lt;/P&gt;&lt;P&gt;I would like the map extent to be identical for each exported image.&lt;/P&gt;&lt;P&gt;I would like the aspect ratio of the image to be 16:9.&lt;/P&gt;&lt;P&gt;Is there a way automate this export process?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 10:32:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/export-multiple-layers-individually-to-image-same/m-p/1388604#M79518</guid>
      <dc:creator>AA25</dc:creator>
      <dc:date>2024-02-29T10:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: Export multiple layers individually to image, same extent, arcgis pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/export-multiple-layers-individually-to-image-same/m-p/1388719#M79521</link>
      <description>&lt;P&gt;The script below worked for me. Please check its safe for yourself. I accept no responsibility for its effects.&lt;/P&gt;&lt;P&gt;It exports layers in the "export" group based on "layout1" to images.&lt;/P&gt;&lt;P&gt;If there is a better way to do this, I would be interested to know. Thanks!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

# Get the username of the current user to construct dynamic paths
username = os.getlogin()

# Construct the project path dynamically
project_path = f"C:\\Users\\{username}\\Desktop\\project\\project.aprx"

# Construct the export path dynamically
export_path = f"C:\\Users\\{username}\\Desktop\\project\\export"
if not os.path.exists(export_path):
os.makedirs(export_path)

# Load the ArcGIS Pro project
aprx = arcpy.mp.ArcGISProject(project_path)

# Obtain references to the specified layout and map
layout = aprx.listLayouts("layout1")[0]
map = aprx.listMaps("map1")[0]

# Get the group layer named "export" within the map
export_group_layer = None
for lyr in map.listLayers():
if lyr.isGroupLayer and lyr.name == "export":
export_group_layer = lyr
break

if export_group_layer is not None:
# Iterate through each layer in the "export" group
for layer in export_group_layer.listLayers():
# Make the current layer visible and all others in the group invisible
for lyr in export_group_layer.listLayers():
lyr.visible = (lyr == layer)

# Construct the export file name and path
export_file_name = f"{layer.name}.png"
export_file_path = os.path.join(export_path, export_file_name)

# Export the layout to image
layout.exportToPNG(export_file_path)

print(f"Exported {layer.name} to {export_file_path}")

else:
print("Group layer 'export' not found in the specified map.")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 12:18:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/export-multiple-layers-individually-to-image-same/m-p/1388719#M79521</guid>
      <dc:creator>AA25</dc:creator>
      <dc:date>2024-02-29T12:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: Export multiple layers individually to image, same extent, arcgis pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/export-multiple-layers-individually-to-image-same/m-p/1388731#M79522</link>
      <description>&lt;P&gt;Great &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/770793"&gt;@AA25&lt;/a&gt;&amp;nbsp;, you found it! I did some tests on my end, and was able to export separate images. (Extent is set through layout itself, I was unable to set it through code). Hope this helps as well.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

# Set the workspace
arcpy.env.workspace = r"C:\Users\geete\Downloads\exported"

# Set the map document
aprx = arcpy.mp.ArcGISProject("CURRENT")
map = aprx.listMaps("Map")[0]  

# Get the extent of the map
#map_extent = map.defaultCamera.getExtent()

# Create a new layout for exporting
layout = aprx.listLayouts()[0] 

# Iterate through each layer in the map
for layer in map.listLayers():
    # Turn off all layers except the current one
    for lyr in map.listLayers():
        if lyr == layer:
            lyr.visible = True
        else:
            lyr.visible = False

    # Set the extent of the layout map frame
    layout_map_frame = layout.listElements('MAPFRAME_ELEMENT')[0]

    # Define output PNG filename
    output_png = os.path.join(r"C:\Users\geete\Downloads\exported", f"{layer.name}.png")

    # Export the layout to PNG
    layout.exportToPNG(output_png, resolution=60)

    # Reset visibility of all layers
    for lyr in map.listLayers():
        lyr.visible = True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 12:50:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/export-multiple-layers-individually-to-image-same/m-p/1388731#M79522</guid>
      <dc:creator>GeeteshSingh07</dc:creator>
      <dc:date>2024-02-29T12:50:29Z</dc:date>
    </item>
  </channel>
</rss>

