0

I would like to know if it is possible to do automatic radiometric normalization for several images in a time series (an image collection i have created) to a single reference. I have found some useful code on stack overflow [here] (Normalization in Google Earth Engine) but it normalizes images interactively. I want to do the same but for an image collection. Also i am well aware that this is possible in other tools but i have to do it in google earth engine and by using javascript if possible. This is my code so far:

function maskS2clouds(image) {
  var qa = image.select('QA20');

  // Bits 10 and 11 are clouds and cirrus, respectively.
  //This operator shifts the first operand the specified number of bits to the left.
  //Bitwise shifting any number x to the left by y bits yields x * 2 ** y.
  //So e.g.: 9 << 3 translates to: 9 * (2 ** 3) = 9 * (8) = 72.
  //var cloudBitMask = 1 << 10;//equals 1024
  //var cirrusBitMask = 1 << 11;//equals 2048
  //alternative
  var cloudBitMask = ee.Number(2).pow(10).int();
  var cirrusBitMask = ee.Number(2).pow(11).int();

  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
      .and(qa.bitwiseAnd(cirrusBitMask).eq(0));

  return image.updateMask(mask).divide(10000);

}


var image_collection_creator = function( listSize){

  var sequence = ee.List.sequence(0, ee.Number(listSize).subtract(1));

  return ee.ImageCollection(sequence.map(function(index){
    var imageCollection = ee.ImageCollection(sentinel2_1C_ImageCollection)
      .filterBounds(interestRectangle) //changed here your geometrical shape
      .filterDate(ee.Date(startPeriodList.get(index)), ee.Date(finishPeriodList.get(index)))
      .sort('CLOUDY_PIXEL_PERCENTAGE', false)
      .map(function(image){return image.clip(interestRectangle)})
      .map(maskS2clouds);

    return imageCollection.reduce(ee.Reducer.lastNonNull());

  }));
};

var dividedImageCollection = image_collection_creator(10);

where startPeriodList and finishPeriodList are two list of strings containing dates of interest

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.