"Error 000999: Failed to get raster" with MosaicToNewRaster

400
0
08-19-2022 06:24 AM
Labels (3)
BeckB
by
New Contributor III

I'm using ArcGIS Pro 3.0.1. I have a collection of files named like 20190129-0000000000-0000000000.tif, 20190129-0001802240-0000000000.tif, 20190212-0000884736-0000000000.tif, etc. that I'd like to merge by the first 8 characters (i.e. 20190129.tif, 20190212.tif). I have ArcPy code that has worked for the same purpose previously, but when I run it for this folder, I get the error:

ExecuteError                              Traceback (most recent call last)
In  [4]:
Line 29:    arcpy.MosaicToNewRaster_management(lstInputs2016,r"G:\My Drive\work\Northern Animal Ecology Lab\sentineltif\evi2019test",outputname, "", "32_BIT_FLOAT", "", "1", "MEAN")

File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py, in MosaicToNewRaster:
Line 19856: raise e

File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py, in MosaicToNewRaster:
Line 19853: retval = convertArcObjectToPythonObject(gp.MosaicToNewRaster_management(*gp_fixargs((input_rasters, output_location, raster_dataset_name_with_extension, coordinate_system_for_the_raster, pixel_type, cellsize, number_of_bands, mosaic_method, mosaic_colormap_mode), True)))

File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py, in <lambda>:
Line 512:   return lambda *args: val(*gp_fixargs(args, True))

ExecuteError: ERROR 000999: Failed to get raster. Please check if the input parameters is correct.
Failed to execute (MosaicToNewRaster).

Here is the code I'm using. Why am I getting this error?

 

# Read tiff files in folder into a list
folder2016 = r"G:\My Drive\work\Northern Animal Ecology Lab\sentineltif\evi2019null"
lstTIFFS2016 = glob.glob(folder2016 + r"\*.tif")

# Create special dictionary where the items will be inserted into a set
dicFiles2016 = collections.defaultdict(set)

# Build dictionary, key is day and item is a set of characters
for fp in lstTIFFS2016:
    fn = os.path.basename(fp)[:-4]
    character = fn[-22:] 
    day = fn[:-22] 
    dicFiles2016[day].add(character)

# Mosaic data for each day
for k,v in dicFiles2016.items():
    # create empty list of files for a single day
    lstInputs2016 = list()

    # Build full path and insert into list
    for character in v:
        fp = folder2016 + "\\" + k + character + ".tif"
        lstInputs2016.append(fp)

    # Mosaic data
    outputname = "Merged_" + k + ".tif"
    print(lstInputs2016)
    arcpy.MosaicToNewRaster_management(lstInputs2016,r"G:\My Drive\work\Northern Animal Ecology Lab\sentineltif\evi2019test",outputname, "", "32_BIT_FLOAT", "", "1", "MEAN")

 

0 Kudos
0 Replies