I am using the Arcpy-package for Python 2.7 (with Arcgis 10.1). I tried to write a script that is mosaicing all rasters in my directory, where they overlap it should calculate the mean for the rasters.

This is my script:

import arcpy

arcpy.env.workspace = "D:/RSIV/Masterarbeit/GRD/Norway/Neu/SentinelSat"

# Import all raster with .TIF in the environment.
rasters = arcpy.ListRasters("*", "TIF")
arcpy.Mosaic_management (rasters[1:],rasters[0] , "MEAN","FIRST","0", "0", "", "0", "")

It works fine, at least its producing the result and overwriting the first raster, but the values are simply wrong for some parts of the image. The image below shows the identify-tool from ArcMap 10.1, as you can see there is no data in 2 of 3 bands, but the Mean is a little bit of the expected value.

enter image description here

If someone can tell me where I have to update my script/what is going on with the data I would be super thankful. Note: I do not have to use Arcpy for this, if there are other packages I am willing to use them, even for python3.X. (Right now I am thinking about Rasterio but I did not work with it before, will give it a read tomorrow)

  • You have some very odd values in your rasters at least in terms of what Arc is displaying in both the TOC and when using the Identify tool. Your mosaiced Mean raster has a minimum value of 0,133155. The values in your original rasters are 0,0000. These values make no sense.
    – F_Kellner
    Oct 18, 2019 at 16:46

1 Answer 1


There is likely some amount of resampling going on, which makes your identify example an inappropriate test.

You could try resampling the rasters as a preprocessing step, using one common raster to snap the others to. Then you can use identify to check the mean against the input (pre-snapped) rasters.

  • Thanks for the hint, i will give it a try with resampling
    – Felix
    Oct 19, 2019 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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