I am trying to batch mosaic rasters using arcpy.MosaicToNewRaster_management in arcpy:
<SPAN class="kwd" style="color: #8a4a0b;"> </SPAN>
#This is for mosaicking rasters
import arcpy
from arcpy import env
#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"
projection = arcpy.SpatialReference(4326)
coordinate_system = projection
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"]
for raster in range(0,4):
output_list = ["Luzon_loss.tif","Palawan_losss.tif","Negros_Panay_loss.tif","Mindanao_loss.tif"]
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], 1, coordinate_system)
print raster+ " is ok!"
print "Finish all of them!"
However, I always get this error:
ExecuteError: ERROR 000622: Failed to execute (Mosaic To New Raster). Parameters are not valid.
ERROR 000628: Cannot set input into parameter coordinate_system_for_the_raster.