I am automating the creation a mosaic raster dataset from thousands of individual elevation tiles and am tying to extract the pixel type metadata from the input tiles and specify this pixel type in arcpy.MosaicToNewRaster(). My tiles are 32-bit float and have a uniform pixel type. If I leave pixel type empty, the default value for MosaicToNewRaster() is 8-bit unsigned, which results in a mosaic where all pixel values are 255. I have tried to use both Describe and RasterInfo on the first tile in the directory and they both return a string '32F'. However, when I use this string value in MosaicToNewRaster, it returns the following error:
ExecuteError: Failed to execute. Parameters are not valid. ERROR 000676: Output file format with specified pixel type or number of bands or colormap is not supported. The suggested pixel type is: 1_BIT Failed to execute (MosaicToNewRaster).
# import arcpy, os # Check out the ArcGIS Spatial Analyst extension license arcpy.CheckOutExtension("Spatial") arcpy.env.workspace = "My_Data_Directory_Path" # Create list of input raster tiles list_opr_tiles = arcpy.ListRasters() list_tile_paths = [os.path.join("My_Data_Directory_Path", tile) for tile in list_opr_tiles] # Instantiate instance of RasterInfo object rasInfo = arcpy.Raster(list_tile_paths).getRasterInfo() # Assign variable to raster's pixelType property string_pixel_type = rasInfo.getPixelType() # Assign variable to raster's bandCount property string_band_count = rasInfo.getBandCount() arcpy.MosaicToNewRaster_management(input_rasters = list_tile_paths, output_location = "My_Output_Directory_Path", raster_dataset_name_with_extension = "My_Mosaic_Name", pixel_type = string_pixel_type, number_of_bands = string_band_count)
I have also tried using Describe and that returns '32F' as well.
string_pixel_type = arcpy.Describe(list_tile_paths).PixelType
When I test what I'm trying to achieve in the Pro GUI and export the Mosaic To New Raster Tool to python I get:
arcpy.management.MosaicToNewRaster( "PROJCS['NAD_1983_2011_UTM_Zone_13N',GEOGCS['GCS_NAD_1983_2011',DATUM['D_NAD_1983_2011',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-105.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]", "32_BIT_FLOAT", 0.5, 1, "LAST", "FIRST")
I can see that if I manually pass a '32_BIT_FLOAT' argument to the MosaicToNewRaster() pixel_type parameter, this will technically work. However, that is not what I want to do as it is not robust (I have a number of projects to run this on and their pixel value could change).
Is there another way that I'm not thinking of to pass the pixel type value? It's unclear to me why MosaicToNewRaster can pick up the cell size and spatial reference system, but not the pixel type or band count from the tiles forming the mosaic.