# Different MIN values from same year's yearly mean composites: one composite from all images and another from monthly composites

I am comparing (maximum & minimum values) yearly composites (both day & night) of Terra MODIS Daily LST 1 km. I calculated using same images but different approaches - just to see if they have any discrepencies. I used 2021 as test year and temperature unit used in degree Celcius.

At first, (after filtering, clipping, and unit conversion) I calculated daytime and nighttime yearly mean composites using all images available, i.e. 364, for the year 2021.

Then, I calculated monthly composites using the same images, i.e. 354 scenes. After that I calculated yearly mean composite using these 12 images (stored in an ImageCollection). I extracted both maximum and minimum values from the composites - yearly composite from all images directly; yearly composite from monthly composites.

To my understanding, these composites should be identical and have same max and min values (of scene). I found same maximum values , however, the minimum values do not match.

Although I used both day and nighttime LST, to keep the question simple, I am going to show code only for nighttime data. In the code below, the min value from yearly composite (calculated from monthly composite) is -18.368 degree Celcius, whereas, yearly composite (from 364 images) returns -16.071 degree Celcius.

Why are maximum value remains same (screenshot 1) but minimum values differ (screenshot 2, and code given below)?

To explore more on the issue, I wanted to map the differences; I subtracted the composites and added the yielded difference image to display. The composites are found with differences in significant amount of pixels. Maybe GEE limits the precision, i.e. decimal places, for calculation of mean, hence underestimation in yearly composite which is based on monthly composites? On the other hand, it it's true then MAX values should mismatch as well, which are not.

It is also interesting that the number of pixels with differences increase as latitude increases (north/south).

GEE code after edit

``````// ******************** DATA IMPORT & FILTER *********************** //
var bound = ee.FeatureCollection('users/salitchakma/SE_Asia_boundary');
var terra = ee.ImageCollection('MODIS/061/MOD11A1').filter(ee.Filter.date('2021-01-01', '2021-12-31'));

// ******************************** FUNCTIONS ***************************** //
var bitwiseExtract = function(input, fromBit, toBit) {
};

// Quality filter for nighttime data
var quality_night = function(img) {
var lstNight = img.select('LST_Night_1km');
var qcNight = img.select('QC_Night');
var qaMask = bitwiseExtract(qcNight, 0, 1).lte(1);
var dataQualityMask = bitwiseExtract(qcNight, 2, 3).eq(0);  // Only good quality data (flag:0)
var emissivityMask = bitwiseExtract(qcNight, 4, 5).lte(1);    // No more than 0.02 emissivity error
var lstErrorMask = bitwiseExtract(qcNight, 6, 7).lte(1);    // No more than 2K LST error
};

// Function to clip each image; adding pixel counts to a property, 'pixel_count'
var clipped = function (img) {
img = img.clip(bound);
return img
.copyProperties(img,['system:time_start','system:time_end']);
};

// Function to convert kelvin to degree celcius
var kelvin_celcius = function(img){
return img
.multiply(0.02)
.subtract(273.15)
.copyProperties(img,['system:time_start','system:time_end']);
};

// To get monthly mean composite
var months = ee.List.sequence(1, 12);
var monthly = function (m) {
var avg_img = imgCol.filter(ee.Filter.calendarRange(m, m, 'month')).mean();
return avg_img;
};

// Quality filter application
var terra_night = terra.map(quality_night);

// Clips to study area
var terra_night_clip = terra_night.map(clipped);

// converts kelvin to celcius
var terra_night_celcius = terra_night_clip.map(kelvin_celcius);

// Monthly mean composite image collection
var imgCol = terra_night_celcius;   // Sets up image collection on which monthly function will be mapped
var terra_night_monthly = ee.ImageCollection.fromImages(
months.map(monthly));

// Yearly mean composite from months' mean composites
var mon_yearly_mean = terra_night_monthly.mean();

//Yearly mean composite from 2021's imgCol
var yearly_mean = terra_night_celcius.mean();

// ************** FINDING MIN *************
var mon_yearly_min = mon_yearly_mean.reduceRegion({
reducer: ee.Reducer.min(),
geometry: bound,
scale: 1000,
maxPixels: 1e9,
bestEffort: true
});

var yearly_min = yearly_mean.reduceRegion({
reducer: ee.Reducer.min(),
geometry: bound,
scale: 1000,
maxPixels: 1e9,
bestEffort: true
});
print("MINIMUM:",
"Monthly to Yearly composite min value:", mon_yearly_min.values(['LST_Night_1km']).get(0), // Returns -18.368374999999975
"Yearly composite min value:", yearly_min.values(['LST_Night_1km']).get(0)  // Returns -16.071111111111083, therefore the values do not match
);

// ********** EDIT 1  *****************
var diff = yearly_mean.subtract(mon_yearly_mean);
var params = {min: -2, max: 2, palette:['red','white','green']};