1

I have been able to display NDVI value in my project but I need some single certain band reflectance value for my data. I have tried in showing blue band (B2) but when I check the inspector tab, the number represent DN and not reflectance.

How do I display single band reflectance value in earth engine? Been searching and did not find the answer yet.

Below is my script:

var sentinelns = ee.ImageCollection('COPERNICUS/S2_SR')
                   .filterDate('2019-01-01', '2019-12-30')
                .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 95))
                .map(maskS2clouds)
                .median()
                .clip(geometry);
             
function maskS2clouds(image) {
  var qa = image.select('QA60');
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
      .and(qa.bitwiseAnd(cirrusBitMask).eq(0));
  return image.updateMask(mask).divide(1);
}  

var SingleBandBlue = sentinelns.select(['B2']);
var BlueParam = { min: 0, max: 1000,};

Map.addLayer(SingleBandBlue, BlueParam, 'Sentinel B2');

1 Answer 1

0

You can find the detailed information for Sentinel 2 Level-2A collection here: https://developers.google.com/earth-engine/datasets/catalog/COPERNICUS_S2_SR#bands

You can see that reflectance band's scale is 0.0001, which means that the value has been re-scaled using that factor. To get that value back you can simply multiply by the scale:

var sentinelns = ee.ImageCollection('COPERNICUS/S2_SR')
                   .filterDate('2019-01-01', '2019-12-30')
                .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 95))
                .map(maskS2clouds)
                .map(function(i){return i.multiply(0.0001)})
                .median()
                .clip(geometry);
             
function maskS2clouds(image) {
  var qa = image.select('QA60');
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
      .and(qa.bitwiseAnd(cirrusBitMask).eq(0));
  return image.updateMask(mask).divide(1);
}  

var SingleBandBlue = sentinelns.select(['B2']);
// don't forget to change visualization parameters
var BlueParam = { min: 0, max: 0.2};

Map.addLayer(SingleBandBlue, BlueParam, 'Sentinel B2');
1
  • Hello, Rodrigo Many thanks for sharing this! yes it works. I also just realized that the Digital Number divide 10k is the reflectance value. I thought this should be computed using various atmospheric parameters. Commented Sep 28, 2020 at 0:06

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.