<?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: Exporting Data Driven Pages to JPEG - modeling export location as parameter in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/exporting-data-driven-pages-to-jpeg-modeling/m-p/652820#M50850</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Pleasure Jerry &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 18 Feb 2016 15:12:41 GMT</pubDate>
    <dc:creator>PeterWilson</dc:creator>
    <dc:date>2016-02-18T15:12:41Z</dc:date>
    <item>
      <title>Exporting Data Driven Pages to JPEG - modeling export location as parameter</title>
      <link>https://community.esri.com/t5/python-questions/exporting-data-driven-pages-to-jpeg-modeling/m-p/652816#M50846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am still new to Python and I am stuck on how to allow the user of the tool to set the location of the resulting JPEGs. The script I have so far is below &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy,os,sys&lt;/P&gt;&lt;P&gt;import arcpy.mapping&lt;/P&gt;&lt;P&gt;import arcpy.utils&lt;/P&gt;&lt;P&gt;import arcpy.arcobjects&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import_path = r"C:\GIS_DATA\Python_Scripts\python_jpeg_example.mxd"&amp;nbsp;&amp;nbsp; # Path of .mxd&lt;/P&gt;&lt;P&gt;export_path = r"C:\GIS_DATA\Python_Scripts"&amp;nbsp;&amp;nbsp; # Path of output file&lt;/P&gt;&lt;P&gt;field_name = "DIST_NAME" # Name of field used to sort DDP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument(import_path)&lt;/P&gt;&lt;P&gt;for i in range(1, mxd.dataDrivenPages.pageCount + 1):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; mxd.dataDrivenPages.currentPageID = i&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; row = mxd.dataDrivenPages.pageRow&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; print row.getValue(field_name)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; print export_path + "." + row.getValue(field_name) + ".jpg"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToJPEG(mxd, export_path + "." + row.getValue(field_name) + ".jpg")&lt;/P&gt;&lt;P&gt;del mxd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When adding the tool in I set the export path as a parameter (set to workspace). No mater where it is set it always drops it in c:\GIS_DATA.&amp;nbsp; I thought I could use GetParameterAsText but I want the user to navigate to the folder they want the JPEGs to reside instead of having to type in the location.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2016 14:29:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-data-driven-pages-to-jpeg-modeling/m-p/652816#M50846</guid>
      <dc:creator>JerryGarcia1</dc:creator>
      <dc:date>2016-02-17T14:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data Driven Pages to JPEG - modeling export location as parameter</title>
      <link>https://community.esri.com/t5/python-questions/exporting-data-driven-pages-to-jpeg-modeling/m-p/652817#M50847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know the Python hot shots on this board will chime in with excellent answers. I have used the Tkinter module for opening a browse file dialog (well, really the tkFileDialog). Here is a brief example I found on Stack Exchange:&lt;/P&gt;&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/19944712/browse-for-file-path-in-python" title="http://stackoverflow.com/questions/19944712/browse-for-file-path-in-python"&gt;http://stackoverflow.com/questions/19944712/browse-for-file-path-in-python&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This may work for you&lt;/P&gt;&lt;P&gt;(plus, it will help for you to format your code in your forum post as code instead of just text)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2016 14:45:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-data-driven-pages-to-jpeg-modeling/m-p/652817#M50847</guid>
      <dc:creator>AdrianWelsh</dc:creator>
      <dc:date>2016-02-17T14:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data Driven Pages to JPEG - modeling export location as parameter</title>
      <link>https://community.esri.com/t5/python-questions/exporting-data-driven-pages-to-jpeg-modeling/m-p/652818#M50848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jerry&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason that its writing the results out to &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;STRONG&gt;"C:\GIS_DATA"&lt;/STRONG&gt; is that the export path has been set to that directory manually. What you want to do is set the &lt;STRONG&gt;input_mxd&lt;/STRONG&gt; and &lt;STRONG&gt;output_folder&lt;/STRONG&gt; to become arguments that you can supply as the user of the script.&amp;nbsp; You need to set your &lt;STRONG&gt;input_mxd&lt;/STRONG&gt; and &lt;STRONG&gt;output_folder&lt;/STRONG&gt; variables to &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//03q300000090000000" rel="nofollow noopener noreferrer" target="_blank"&gt;arcpy.GetParameterAsText &lt;/A&gt;to change the input and output arguments for each time you run the script as a tool within ArcGIS. I've cleaned your code a bit and gave explanations why.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;'''
Created on Feb 17, 2016

Export Data Driven Pages

to jpegs

@author: PeterW
'''
# I've removed the unnecessary modules that you imported

# import modules and site-packages
import os
import arcpy

# set input and output arguments
input_mxd = arcpy.GetParameterAsText(0)
output_folder = arcpy.GetParameterAsText(1)
field_name = r"DIST_NAME"

# export each data driven page out as a jpeg 
mxd = arcpy.mapping.MapDocument(input_mxd)
for i in range(1, mxd.dataDrivenPages.pageCount + 1):
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.dataDrivenPages.currentPageID = i
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = mxd.dataDrivenPages.pageRow
&amp;nbsp;&amp;nbsp;&amp;nbsp; # I've created a variable page_name to store the current page name
&amp;nbsp;&amp;nbsp;&amp;nbsp; page_name = row.getValue(field_name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Processing {}".format(page_name))
&amp;nbsp;&amp;nbsp;&amp;nbsp; # I've used os.path.join to join the path and file name for the output jpegs
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToJPEG(mxd, os.path.join(output_folder,&amp;nbsp; page_name + ".jpg"))
del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:40:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-data-driven-pages-to-jpeg-modeling/m-p/652818#M50848</guid>
      <dc:creator>PeterWilson</dc:creator>
      <dc:date>2021-12-12T03:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data Driven Pages to JPEG - modeling export location as parameter</title>
      <link>https://community.esri.com/t5/python-questions/exporting-data-driven-pages-to-jpeg-modeling/m-p/652819#M50849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for all your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Feb 2016 14:00:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-data-driven-pages-to-jpeg-modeling/m-p/652819#M50849</guid>
      <dc:creator>JerryGarcia1</dc:creator>
      <dc:date>2016-02-18T14:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data Driven Pages to JPEG - modeling export location as parameter</title>
      <link>https://community.esri.com/t5/python-questions/exporting-data-driven-pages-to-jpeg-modeling/m-p/652820#M50850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Pleasure Jerry &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Feb 2016 15:12:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-data-driven-pages-to-jpeg-modeling/m-p/652820#M50850</guid>
      <dc:creator>PeterWilson</dc:creator>
      <dc:date>2016-02-18T15:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting Data Driven Pages to JPEG - modeling export location as parameter</title>
      <link>https://community.esri.com/t5/python-questions/exporting-data-driven-pages-to-jpeg-modeling/m-p/1066677#M61322</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;could you explain me how to set the input and output parameters?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jun 2021 22:05:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-data-driven-pages-to-jpeg-modeling/m-p/1066677#M61322</guid>
      <dc:creator>gcastro</dc:creator>
      <dc:date>2021-06-09T22:05:07Z</dc:date>
    </item>
  </channel>
</rss>

