This is just a continuation of my former post:Batch Mosaic Rasters: arcpy.MosaicToNewRaster_management (ERROR 000628: Cannot set input into parameter coordinate_system_for_the_raster) --where I batch process mosaic rasters using arcpy.MosaicToNewRaster_management. The first file from the "list_all_rasters" has been successfully processed but the next file was not. Pretty weird, since all of my input rasters have the same number of bands and other properties.
This is my code:
#This is for mosaicing rasters import arcpy from arcpy import env env.overwriteOutput = True #Set the current workspace and other env 't variables env.workspace = r"C:\thesis\for_sampling\sampling_outputs\new_loss" env.nodata = "MINIMUM" env.compression = "LZ77" list_all_rasters = ["newlossGreater_Luzonforests_onlyloss_20N_120E.tif;newlossGreater_Luzonforests_onlyloss_30N_120E.tif;\newlossGreater_Luzonforests_onlyloss_20N_110E.tif","newlossGreater_Palawanforests_onlyloss_20N_120E.tif;\newlossGreater_Palawanforests_onlyloss_10N_110E.tif;\newlossGreater_Palawanforests_onlyloss_20N_110E.tif",\"newlossGreater_Negros_Panayforests_onlyloss_10N_120E.tif;newlossGreater_Negros_Panayforests_onlyloss_10N_110E.tif",\"newlossGreater_Mindanaoforests_onlyloss_10N_120E.tif;newlossGreater_Mindanaoforests_onlyloss_10N_110E.tif;\newlossGreater_Mindanaoforests_onlyloss_20N_110E.tif"] output_list = ["Luzon_loss_try.tif","Palawan_loss_try.tif","Negros_Panay_loss_try.tif","Mindanao_loss_try.tif"] for raster in range(0,3): env.workspace = r"C:\thesis\for_sampling\sampling_outputs\new_loss" print raster # checking the list arcpy.MosaicToNewRaster_management(list_all_rasters[raster], r"C:\thesis\for_sampling\sampling_outputs", \ output_list[raster], "GCS_WGS_1984.prj", "1_BIT", "0.00025", 1) print "Finish all of them!"And this is the error message:
ExecuteError: Failed to execute. Parameters are not valid. ERROR 000157: Input and target dataset should have the same number of bands Failed to execute (MosaicToNewRaster).I'm pretty sure that that my input files are set to have the same number bands with my output files ( which is 1, in this case). I've double checked my files, and all of them are not corrupted.
أكثر...
This is my code:
#This is for mosaicing rasters import arcpy from arcpy import env env.overwriteOutput = True #Set the current workspace and other env 't variables env.workspace = r"C:\thesis\for_sampling\sampling_outputs\new_loss" env.nodata = "MINIMUM" env.compression = "LZ77" list_all_rasters = ["newlossGreater_Luzonforests_onlyloss_20N_120E.tif;newlossGreater_Luzonforests_onlyloss_30N_120E.tif;\newlossGreater_Luzonforests_onlyloss_20N_110E.tif","newlossGreater_Palawanforests_onlyloss_20N_120E.tif;\newlossGreater_Palawanforests_onlyloss_10N_110E.tif;\newlossGreater_Palawanforests_onlyloss_20N_110E.tif",\"newlossGreater_Negros_Panayforests_onlyloss_10N_120E.tif;newlossGreater_Negros_Panayforests_onlyloss_10N_110E.tif",\"newlossGreater_Mindanaoforests_onlyloss_10N_120E.tif;newlossGreater_Mindanaoforests_onlyloss_10N_110E.tif;\newlossGreater_Mindanaoforests_onlyloss_20N_110E.tif"] output_list = ["Luzon_loss_try.tif","Palawan_loss_try.tif","Negros_Panay_loss_try.tif","Mindanao_loss_try.tif"] for raster in range(0,3): env.workspace = r"C:\thesis\for_sampling\sampling_outputs\new_loss" print raster # checking the list arcpy.MosaicToNewRaster_management(list_all_rasters[raster], r"C:\thesis\for_sampling\sampling_outputs", \ output_list[raster], "GCS_WGS_1984.prj", "1_BIT", "0.00025", 1) print "Finish all of them!"And this is the error message:
ExecuteError: Failed to execute. Parameters are not valid. ERROR 000157: Input and target dataset should have the same number of bands Failed to execute (MosaicToNewRaster).I'm pretty sure that that my input files are set to have the same number bands with my output files ( which is 1, in this case). I've double checked my files, and all of them are not corrupted.
أكثر...