Hi,
it is possible to compute median of each pixel from multiple images of the same area?
Thank you
Assuming that your images have the same geographical footprint and the same projection, you can open all of them in SNAP and apply a band math on them. Here’s an example with 4 Sentinel-2 L2A products over the same area (40RDN):
Then you need to prefix each band with the product index in the formula, like in the Expression editor above.
Hope this helps.
Hi, thank you for your response. I have the same footprint and projection. I tried band maths, but median operator is missing in list of operators.
If the mean is okay for you, you can follow the approach Cosmin suggested. This has the benefit that the resolution is maintained.
But you could also us the mosaic tool.
If you need the median, you can use the binning tool.
Select the Percentile aggregator and set the value to 50.
Here the downside is that the reference system and the resolution are not maintained.
Hi, I need to compute median values. I will try binnig tool. Thank you.
Alternatively try r.series in QGIS/GRASS GIS: Makes each output cell value a function of the values assigned to the corresponding cells in the input raster map layers including the median. However, this interrupts the workflow and does not maintain the band naming conventions from SNAP.
Generally, I was hoping too for a function to calculate the Median being included in SNAP 10, e.g. in Raster/ Band Maths/ Functions or more specifically under Radar/ Coregistration/ Stack Tools/ Stack Averging/ Processing Parameters/ Statistic
Is there a chance for this being included in the future?
I will release a plugin for SNAP this week which allows to calculate the mean of multiple bands via the Band Maths. Not only the mean but also min and max of multiple bands. And all functions exclude NaN, infinite and invalid pixels from the calculation.
Marco from EOMasters - Mastering Earth Observation
Thanks @Marco_EOM for your supportive efforts. Curious to work with and try the functionalities of the announced plugin.
The plugin is now released. Have a look at the EOMasters Toolbox.
Dear colleagues,
I would like to support the suggestion to include the median as a standard function in band math. Calculating the mean is not an appropriate alternative, since strong outliers may affect or distort the result. Median is a good solution to get rid of dark and bright pixels in a multitemporal stack. Another benefit is that it returns a real value that has been measured in one of the pixels, instead of calculating an artificial new value. By these means the median can be applied to categorical rasters such as classifications too, where the mean cannot help.
Thanks to @Marco_EOM for developing the Band Maths Extensions. Would sth like this: medianOf(ndvi_2020, ndvi_2021, ndvi_2022, … ) be also possible?
In a perfect world, the median function would be also included under Radar → Coregistration → Stack Tools → Stack Averaging → Processing Parameters → Statistic → MEDIAN ![]()
Thank you very much for your consideration.
Thanks @franck for this suggestion.
Actually I though I have included this already, but obviously not. Now it is included.
It’s not particularly fast, but that’s just the way it is.
I have provided the new version v2.0.1 of the EOMasters Toolbox to the SNAP team and it should be available via the Plugin Manager some time soon.
Snippet from the help page:
The integration into the radar processing must be done by the SNAP team.
Hi @Marco_EOM , thank you very much for your reply and your great support, much appreciated!
I will update EOMTBX to 2.0.1. as soon as it becomes available, thank you again. Should I post about the proposal regarding Stack Averaging in the Microwave Toolbox to reach the SNAP team?


