<?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 to Multiple PNG - Project contains several MapSeries in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/export-to-multiple-png-project-contains-several/m-p/1310743#M68219</link>
    <description>&lt;P&gt;thanks, Andrew. the wildcard solution is exactly what I was looking for. Cheers&lt;/P&gt;</description>
    <pubDate>Sat, 22 Jul 2023 00:21:06 GMT</pubDate>
    <dc:creator>APYahoo</dc:creator>
    <dc:date>2023-07-22T00:21:06Z</dc:date>
    <item>
      <title>Export to Multiple PNG - Project contains several MapSeries</title>
      <link>https://community.esri.com/t5/python-questions/export-to-multiple-png-project-contains-several/m-p/1309859#M68209</link>
      <description>&lt;P&gt;Hi. I've got a Python script for exporting a MapSeries to PNG in a Project that contains multiple MapSeries. My can't seem to figure out how to specify the MapSeries to export. I've included the script below.&amp;nbsp; I've been tweaking the layout_number values. It does change the MapSeries output, but I'm not sure how to determine the layout number?&amp;nbsp; Any suggestions?&amp;nbsp; Or is there a way to specify by "layout_name"?&amp;nbsp; Thanks&lt;BR /&gt;_______________________________________________________&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;import arcpy, os, sys, pathlib&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;output_folder = pathlib.Path(os.path.dirname(sys.argv[0])) / "Output"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;output_png_fname_pattern = "{this_row.Index}_{this_row.Index}.png"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;layout_number = 0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;output_folder = pathlib.Path(output_folder)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;os.makedirs(output_folder, exist_ok=True)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;p = arcpy.mp.ArcGISProject("CURRENT")&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;l = p.listLayouts()[layout_number]if not (l.mapSeries is None):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;ms = l.mapSeries&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;if ms.enabled:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;for pageNum in range(1, ms.pageCount + 1):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;ms.currentPageNumber = pageNum&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;this_row = ms.pageRow&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;output_fname = output_png_fname_pattern.format(this_row=this_row)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;l.exportToPNG(output_folder / output_fname,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;transparent_background=True,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;clip_to_elements=True,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;resolution=300)&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 23:43:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-to-multiple-png-project-contains-several/m-p/1309859#M68209</guid>
      <dc:creator>APYahoo</dc:creator>
      <dc:date>2023-07-19T23:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Export to Multiple PNG - Project contains several MapSeries</title>
      <link>https://community.esri.com/t5/python-questions/export-to-multiple-png-project-contains-several/m-p/1310629#M68218</link>
      <description>&lt;P&gt;I'm not sure how the index numbers for the layouts get assigned -- they seem kind of arbitrary to me. Possibly it depends on the order that in which the layouts were created?&lt;/P&gt;&lt;P&gt;The layouts do have a name attribute, which you could use to construct a dictionary:&lt;/P&gt;&lt;PRE&gt;layouts = p.listLayouts()&lt;BR /&gt;l_dict = {l.name: l &lt;SPAN&gt;for &lt;/SPAN&gt;l &lt;SPAN&gt;in &lt;/SPAN&gt;layouts if not l.mapSeries is None}&lt;/PRE&gt;&lt;P&gt;Alternately, if you know the name, you can use it as a wildcard when you call p.listLayouts():&lt;/P&gt;&lt;PRE&gt;l = p.listLayouts("yournamehere")[0]&lt;/PRE&gt;&lt;P&gt;Note that the [0] is required even when searching for an exact name with only a single match among your layouts, because listLayouts() returns that match inside a list object.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 18:26:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-to-multiple-png-project-contains-several/m-p/1310629#M68218</guid>
      <dc:creator>AndrewBryson1</dc:creator>
      <dc:date>2023-07-21T18:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Export to Multiple PNG - Project contains several MapSeries</title>
      <link>https://community.esri.com/t5/python-questions/export-to-multiple-png-project-contains-several/m-p/1310743#M68219</link>
      <description>&lt;P&gt;thanks, Andrew. the wildcard solution is exactly what I was looking for. Cheers&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jul 2023 00:21:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-to-multiple-png-project-contains-several/m-p/1310743#M68219</guid>
      <dc:creator>APYahoo</dc:creator>
      <dc:date>2023-07-22T00:21:06Z</dc:date>
    </item>
  </channel>
</rss>

