2

I am working with S5P data for NO2. I have an image collection and want to obtain the mean NO2 for specified filters. The following code is from the documentation.

var collection = ee.ImageCollection('COPERNICUS/S5P/NRTI/L3_NO2')


.select('NO2_column_number_density')
  .filterDate('2019-06-01', '2019-06-06');

var band_viz = {
  min: 0,
  max: 0.0002,
  palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};

Map.addLayer(collection.mean(), band_viz, 'S5P N02');
Map.addLayer(meanImage,band_viz, 'another method');

I was wondering what is the use of reduce method on ImageCollection when there is a mean method already available.

var meanImage = collection.reduce(ee.Reducer.mean());

What is the difference between applying mean directly versus using reduce method

1 Answer 1

3

Did you look at the Earth Engine documentation for ImageCollection reductions?

For basic statistics like min, max, mean, etc., ImageCollection has shortcut methods like min(), max(), mean(), etc. They function in exactly the same way as calling reduce(), except the resultant band names will not have the name of the reducer appended.

In other words, the result is the same if you use .mean() or .reduce(ee.Reducer.mean()) but the latter method will append _mean to the band names.

1
  • Yes I did look up the documentation. Did not find any difference. Now that you say, reduce might be helpful for complex functional calculations, cleared things up. This helped! Jun 25, 2020 at 8:32

Your Answer

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

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