I am trying to reduce the resolution of 10m bands (B2-4,B8) to 20m resolution so that I have uniform resolution for all bands I want to use. I tried a solution provided by Jepson Nomad for similar question. I tried to write a function so that I can apply it to image collection. But its not working as no change in resolution is happening like in Jepson's solution. How can I change the resolution to 20m?

var s2= ee.ImageCollection("COPERNICUS/S2_SR").filter(ee.Filter.lt("CLOUDY_PIXEL_PERCENTAGE", 10));
 var admin1 = ee.FeatureCollection("FAO/GAUL_SIMPLIFIED_500m/2015/level1");
    var MP = admin1.filter(ee.Filter.eq('ADM1_NAME', 'Madhya Pradesh'));
    var geometry = MP.geometry();
////vis parameters.
var vis = {bands: ['B4', 'B3', 'B2'], max: 2000, gamma: 1.5};
////Define Study area
var area = ee.FeatureCollection(geometry);
var opacity = 0.5; // number [0-1]
Map.centerObject(area, 6.5);
////Filter Dates
var ImColA1 = ee.ImageCollection(s2.filterDate('2019-05-15', '2019-05-21')  //// Filter by dates.
//// Creat a Cloud Mask.
function maskS2sr(image) {
  var cloudBitMask = ee.Number(2).pow(10).int(); ////cloud band
  var cirrusBitMask = ee.Number(2).pow(11).int();//// cirrus band
  var qa = image.select('QA60'); //// Get the pixel QA band.
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0)  ////  Flags set to zero for clear conditions.
      .and(qa.bitwiseAnd(cirrusBitMask).eq(0)); ////  Flags set to zero for clear conditions.
  return image.updateMask(mask) //// Return the masked image, scaled to TOA reflectance, without the QA bands.
      .copyProperties(image, ["system:time_start"]);

////Add masks
var CM_ImColA1 = ImColA1.map(maskS2sr)

var resample20 = function(image){
  var projection =image.select('B12').projection();
  var bands = image.select('B[2-4]','B8','B8A','B11','B12');
  var resample = image.reproject({
      crs: projection,
      scale: 20
     return bands
var resmap_CM_ImColA1 = CM_ImColA1.map(resample20);

///////Mosaic and Clip//////
var mosA1 = CM_ImColA1.mosaic().clip(area);
var mosA2 = resmap_CM_ImColA1.mosaic().clip(area);
Map.addLayer(mosA1, vis,'MosaicA1');
Map.addLayer(mosA2, vis,'MosaicA2');
  • 2
    If you later on in the calculation use a spatial reducer or export the image, the input will get reprojected to that scale anyway. So in the end most of the time you don't need to explicitly reproject yourself.
    – JonasV
    Aug 5, 2021 at 9:11
  • Hi JonasV! Thanks for your comment. can you please explain more how spatial reducer can solve the problem during calculation? can we use it in function along with the calculation, for example MNDWI calculation that uses B3 (10m) and B11(20m)?
    – Monish
    Aug 5, 2021 at 11:00
  • 2
    When calculating an Index you don't need to resample. If the end result you are exporting is below 20m of resolution, the finer resolution for B3 will be used. If it is at or above 20m it will automatically resample to a coarser resolution. Have a close look at the documentation, it will hopefully clear up things a lot more than I can provide in the comments. developers.google.com/earth-engine/guides/scale
    – JonasV
    Aug 5, 2021 at 13:09

1 Answer 1


I am attaching a piece of your code where you are actually writing resample function. Minor correction there and it will work!

var resample20 = function(image){
  var projection =image.select('B12').projection();
  var bands = image.select('B[2-4]','B8','B8A','B11','B12');
  var resample = bands.reproject({
      crs: projection,
      scale: 20
     return resample 

This is the correction required, after this the bands are reprojected to newer scale!

Your Answer

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

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