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
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
Code:
# 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