ImageCollection Reductions

Consider the example of needing to take the median over a time series of images
represented by an ImageCollection. To reduce an ImageCollection,
use imageCollection.reduce(). This reduces the collection of images to an
individual image as illustrated in Figure 1. Specifically, the output is computed
pixel-wise, such that each pixel in the output is composed of the median value of all the
images in the collection at that location. To get other statistics, such as mean, sum,
variance, an arbitrary percentile, etc., the appropriate reducer should be selected and
applied. (See the Docs tab in the
Code Editor for a list of all the reducers
currently available). 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.

Figure 1. Illustration of an ee.Reducer applied to an ImageCollection.

For an example of reducing an ImageCollection, consider a collection of
Landsat 5 images, filtered by path and row. The following code uses reduce()
to reduce the collection to one Image (here a median reducer is used simply
for illustrative purposes):

This returns a multi-band Image, each pixel of which is the median of all
unmasked pixels in the ImageCollection at that pixel location. Specifically,
the reducer has been repeated for each band of the input imagery. Note that the band names
have the name of the reducer appended: ‘B1_median’, ‘B2_median’,
etc. The output should look something like Figure 2.

Figure 2. A false color composite of the median of Landsat 5 scenes in 2008.