Google Earth Engine Median Function – Understanding the Median Function in GEE

functiongoogle-earth-enginegoogle-earth-engine-javascript-apimedian

I want to do some reprocessing with ee.ImageCollection("NOAA/VIIRS/DNB/MONTHLY_V1/VCMSLCFG"). For example,I want to caculate median value of each pixel in 12 images.

var imageCollection = ee.ImageCollection("NOAA/VIIRS/DNB/MONTHLY_V1/VCMSLCFG");
var nl14 =  imageCollection.filterDate('2014-01-01', '2015-01-01').select('avg_rad');
print('original resolution: ')
print(nl14.first().projection().nominalScale())
var nl14_median = nl14.median();
print('After median function resolution:')
print(nl14_median.projection().nominalScale())

So I use median function,as documentation said:

Reduces an image collection by calculating the median of all values at each pixel across the stack of all matching bands. Bands are matched by name.

However,when I caculate the resolution of original VIIRS Image and Image after median processing, I found the resolution changed,from 463.83 to 111319 meters.So I export these two images to Drive and open it in ArcGIS. The size of latter image changed a lot. Is this median function like a convolution median filter?

enter image description here

enter image description here

Best Answer

I got the answer. It seems ImageCollection.median caculate the median value through 'Bands' key. However, when I select the nlt ImageCollection, 12 images were sent to features key but not bands. So if someone want to caculate the median、mean value of multi channels(images), using ee.reduce(ee.reducer()) instead. The code is listed as follow:

var median_value = image.select('B1','B2','B3','B4','B5','B6','B7','B8','B9','B10','B11','B12') .reduce(ee.Reducer.median()) 
Related Question