<?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 Import multiple rasters into map document, then print to pdf... in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/import-multiple-rasters-into-map-document-then/m-p/618130#M6713</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have about 191 .ecw files to bring into an map document. I've tried to load them with the Add Data button but it crashes ArcGIS. So, I thought I would script it with arcpy.mapping. I have got to a point where I can print a pdf of the first .ecw in the list. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The basic idea is that I want to add all the .ecw's and then print one big pdf of the whole thing. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I'm unsure of how to progress. I'd appreciate some advice on the script, I'm fairly new to Python, and very new to arcpy.mapping, so please keep it simple! Thanks... Here's my script so far...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os from arcpy import env&amp;nbsp; # Workspace inDir = (r'F:\Ortho_prelim\TEST')&amp;nbsp; # Specify map document mxd = arcpy.mapping.MapDocument(r'F:\Imagery.mxd')&amp;nbsp; # Specify data frame df = arcpy.mapping.ListDataFrames(mxd, 'Layers')[0]&amp;nbsp; # Import file&amp;nbsp; dirList = os.listdir(r'F:\Ortho_prelim\TEST') for fname in dirList: &amp;nbsp;&amp;nbsp;&amp;nbsp; if fname.endswith('.ecw'): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print inDir + os.sep + fname &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyrFile = arcpy.mapping.Layer(inDir + os.sep + fname) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(df, lyrFile) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # refresh view and table of contents, save changes to mxd arcpy.RefreshActiveView() arcpy.RefreshTOC() mxd.save() arcpy.mapping.ExportToPDF(mxd, r"F:\Imagery.pdf")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Jan 2013 21:37:05 GMT</pubDate>
    <dc:creator>SamCoggins1</dc:creator>
    <dc:date>2013-01-21T21:37:05Z</dc:date>
    <item>
      <title>Import multiple rasters into map document, then print to pdf...</title>
      <link>https://community.esri.com/t5/mapping-questions/import-multiple-rasters-into-map-document-then/m-p/618130#M6713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have about 191 .ecw files to bring into an map document. I've tried to load them with the Add Data button but it crashes ArcGIS. So, I thought I would script it with arcpy.mapping. I have got to a point where I can print a pdf of the first .ecw in the list. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The basic idea is that I want to add all the .ecw's and then print one big pdf of the whole thing. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I'm unsure of how to progress. I'd appreciate some advice on the script, I'm fairly new to Python, and very new to arcpy.mapping, so please keep it simple! Thanks... Here's my script so far...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os from arcpy import env&amp;nbsp; # Workspace inDir = (r'F:\Ortho_prelim\TEST')&amp;nbsp; # Specify map document mxd = arcpy.mapping.MapDocument(r'F:\Imagery.mxd')&amp;nbsp; # Specify data frame df = arcpy.mapping.ListDataFrames(mxd, 'Layers')[0]&amp;nbsp; # Import file&amp;nbsp; dirList = os.listdir(r'F:\Ortho_prelim\TEST') for fname in dirList: &amp;nbsp;&amp;nbsp;&amp;nbsp; if fname.endswith('.ecw'): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print inDir + os.sep + fname &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyrFile = arcpy.mapping.Layer(inDir + os.sep + fname) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(df, lyrFile) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # refresh view and table of contents, save changes to mxd arcpy.RefreshActiveView() arcpy.RefreshTOC() mxd.save() arcpy.mapping.ExportToPDF(mxd, r"F:\Imagery.pdf")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jan 2013 21:37:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/import-multiple-rasters-into-map-document-then/m-p/618130#M6713</guid>
      <dc:creator>SamCoggins1</dc:creator>
      <dc:date>2013-01-21T21:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: Import multiple rasters into map document, then print to pdf...</title>
      <link>https://community.esri.com/t5/mapping-questions/import-multiple-rasters-into-map-document-then/m-p/618131#M6714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I believe what is happening is each time a raster is added, the df extent is being set only to that raster.&amp;nbsp; You will need to set the df extent prior to export to PDF.&amp;nbsp; The following worked on my 10.1 machine. (note the paths are different).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os from arcpy import env&amp;nbsp; # Workspace inDir = (r'C:\Temp\Images')&amp;nbsp; # Specify map document mxd = arcpy.mapping.MapDocument(r'C:\Temp\Images\Imagery.mxd')&amp;nbsp; # Specify data frame df = arcpy.mapping.ListDataFrames(mxd, 'Layers')[0]&amp;nbsp; # Import file&amp;nbsp; dirList = os.listdir(r'C:\Temp\Images') for fname in dirList: &amp;nbsp;&amp;nbsp;&amp;nbsp; if fname.endswith('.TIF'): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print inDir + os.sep + fname &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyrFile = arcpy.mapping.Layer(inDir + os.sep + fname) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(df, lyrFile) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #set df extent newExtent = df.extent newExtent.XMin, newExtent.YMin = 1017500, 629600 newExtent.XMax, newExtent.YMax = 1023000, 639200 df.extent = newExtent&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, r'C:\Temp\Images\Imagery.pdf'&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note you found a loophole in using arcpy.mapping.Layer.&amp;nbsp; It is intended to add layer files, not source data.&amp;nbsp; The rasters may not render the way that you want them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 13:43:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/import-multiple-rasters-into-map-document-then/m-p/618131#M6714</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2013-01-22T13:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: Import multiple rasters into map document, then print to pdf...</title>
      <link>https://community.esri.com/t5/mapping-questions/import-multiple-rasters-into-map-document-then/m-p/618132#M6715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the response it was very helpful. However, changing the extent will be an issue down the road here as I'm hoping to eventually add the imagery to a map document that uses data driven pages. Plus, you're correct, by adding the source data rather than a layer I have run into the issue that it does not display properly. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So... I thought I could use Python to make the layer and then add the .ecw's to a layer and then use the layer file in my script. Which would would all work well and would mean I don't have to open a map document.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I will need two scripts&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) To make a layer file containing the .ecw files.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) To add the layer file to the map (with data driven pages) and then print all to pdf.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At the moment I'm further along the second script and am working on the first. If I have any more issues I'll post up later... Thanks again&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 20:49:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/import-multiple-rasters-into-map-document-then/m-p/618132#M6715</guid>
      <dc:creator>SamCoggins1</dc:creator>
      <dc:date>2013-01-22T20:49:04Z</dc:date>
    </item>
  </channel>
</rss>

