AnsweredAssumed Answered

Import multiple rasters into map document, then print to pdf...

Question asked by scoggins on Jan 21, 2013
Latest reply on Jan 22, 2013 by scoggins
Hello:

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.

The basic idea is that I want to add all the .ecw's and then print one big pdf of the whole thing.

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...

import arcpy, os from arcpy import env  # Workspace inDir = (r'F:\Ortho_prelim\TEST')  # Specify map document mxd = arcpy.mapping.MapDocument(r'F:\Imagery.mxd')  # Specify data frame df = arcpy.mapping.ListDataFrames(mxd, 'Layers')[0]  # Import file  dirList = os.listdir(r'F:\Ortho_prelim\TEST') for fname in dirList:     if fname.endswith('.ecw'):         print inDir + os.sep + fname         lyrFile = arcpy.mapping.Layer(inDir + os.sep + fname)         arcpy.mapping.AddLayer(df, lyrFile)           # refresh view and table of contents, save changes to mxd arcpy.RefreshActiveView() arcpy.RefreshTOC() mxd.save() arcpy.mapping.ExportToPDF(mxd, r"F:\Imagery.pdf")

Outcomes