scoggins

Multiple rasters to .lyr

Discussion created by scoggins on Jan 24, 2013
Latest reply on Jan 25, 2013 by Wayne_Whitley
Hello:

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    

Outcomes