I'm trying to make a .lyr file to bring into ArcMap with arcpy.mapping. I can bring a single raster into a .lyr with the script below. I'm unsure how to proceed to get multiple rasters from the same folder into a .lyr. Any help appreciated.
Thanks
# Import system modules
import arcpy, os
from arcpy import env
# Workspace Directory
env.workspace = r'F:\Ortho_prelim\TEST'
workspace = r'F:\Ortho_prelim\OUT'
# Set local variables
inLyr = 'ImageLyr'
outLyr0 = 'ImageLyr'
outLyr = workspace + os.sep + 'Image.lyr'
# Make feature layer variables
fList = os.listdir(r'F:\Ortho_prelim\TEST')
for f in fList:
if fList.endswith('.ecw'):
print fList
arcpy.MakeRasterLayer_management(f, outLyr0, "", "")
print 'Made ' + outLyr0
print outLyr0
# Save Feature Layer
arcpy.SaveToLayerFile_management(inLyr, outLyr)
print 'Made layer ' + outLyr
So the pseudo code should be something like:
- Look in folder
- Look up all files with extension .ecw
- Add all the .ecw files in the folder to a .lyr file...