1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| import arcpy import os
arcpy.CheckOutExtension("Spatial") arcpy.env.overwriteOutput = True def mosaicToNewRaster(inputFolder,outputFolder,tempfolder,outputname): infolder = inputFolder + "\\" outfolder = outputFolder + "\\" tempfolder = tempfolder + "\\" rasters = [] datanames = os.listdir(infolder) for dataname in datanames: if os.path.splitext(dataname)[1] == '.tif': print dataname inputfullname = infolder + dataname print "inputfullname: " + inputfullname raster = arcpy.Raster(inputfullname) deldarkfullname = tempfolder + "temp" + dataname arcpy.CopyRaster_management(raster, deldarkfullname, "DEFAULTS", 0, 0, "", "", "8_BIT_UNSIGNED") raster2 = arcpy.Raster(deldarkfullname) rasters.append(raster2) arcpy.MosaicToNewRaster_management(rasters, outfolder, outputname, "", "8_BIT_UNSIGNED", "30", "1", "MINIMUM", "FIRST") print("Mosaic success")
|