I am using ArcPy in ArcMap and have multiple Rasters (Landsat imagery) taken from a given area (Image 1). All rasters set next to each other

My final goal is to create a cloud free image of the complete area. Since the Rasters contain clouds, I first used the BQA given for the data and classified clouds, background, etc for each Raster as nodata. I am doing this to later replace these nodata entries with the entries of other Rasters taken of the same area. When I merge my Rasters with (composites is a list of Rasters)

arcpy.MosaicToNewRaster_management(composites, os.getcwd(), mosaic_name, number_of_bands = number_bands, mosaic_method = 'MAXIMUM')

I obtain a merged image that uses the pixel values of the underlying Raster if its classified as nodata in the above Raster (Image 2).

Rasters combined with MosaicToNewRaster_Management directly

This is exactly the behavior I want to achieve. However, the disadvantage of this approach is that the code is not doing any color balancing, which I require. When I create a mosaic separately and do color balancing

mosaic = arcpy.CreateMosaicDataset_management("C:/Users/georg/OneDrive/Dokumente/ArcGIS/Default.gdb",  mosaic_name, arcpy.Describe(composites[0]).spatialReference,  num_bands = number_bands)
arcpy.SetRasterProperties_management(mosaic,nodata="1 0;2 0;3 0;4 0;5 0;6 0;7 0")
arcpy.DefineMosaicDatasetNoData_management(mosaic, number_bands, "ALL_BANDS '0'")
arcpy.SetMosaicDatasetProperties_management(mosaic, mosaic_operator='MAX')
arcpy.AddRastersToMosaicDataset_management(mosaic, "Raster Dataset", composites)
arcpy.ColorBalanceMosaicDataset_management(mosaic, "DODGING", "COLOR_GRID")
arcpy.MosaicToNewRaster_management(mosaic, os.getcwd(), mosaic_name+".tif", number_of_bands = number_bands, mosaic_method = 'MAXIMUM') 

the final image classifies a pixel as nodata if the top Raster is nodata at this Pixel (Image 3), whereas it should be using a Pixel from the underlying Raster in such a case. How do I fix this problem? I tried many different settings, but none did work. Manual mosaic creation propagates nodata pixels.

  • I'd split originals into bands first and mosaic them.
    – FelixIP
    Mar 25, 2020 at 23:42
  • @FelixIP why do you suggest this?
    – Schorsch
    Mar 26, 2020 at 12:46
  • Because 1 band rasters understand no data better than multiband.
    – FelixIP
    Mar 26, 2020 at 18:44

1 Answer 1


I am not sure why, but this made me solve my problem:

arcpy.BuildSeamlines_management(mosaic, computation_method = 'COPY_FOOTPRINT')

i.e. I changed the computation method of the seamlines to 'COPY_FOOTPRINT'. I think the default computation method created mostly non-overlapping seamlines and then relied for each pixel on a single raster. However, this is not the behavior I wanted, since I wanted to deliberately use my mosaic method to determine what pixels to use.

Bottom-line: building seamlines may conflict with the mosaic method chosen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.