Tuesday, October 15, 2019

Research Note #23 - GEE Script to Overlay Sentinel 2A with MODIS Terra/Aqua Hotspots

The main purpose of this script is to overlay MODIS Terra/Aqua hotspots product MOD14A1/MYD14A1 (daily thermal anomalies, lev3, 1km grid) over Sentinel-2A Thermal Reflectance (lev2, 10-20m spatial resolution). The channels used for Sentinel data is 11, 8 and 4 (SWIR1, NIR, RED) hence creating false color image over area of Sri Mukhtar Sahib city in Punjab region, India (14x zoom) on Google Map. Observation time was set between November 1 - 15, 2018.



/**
 * Function to mask clouds using the Sentinel-2 QA band
 * @param {ee.Image} image Sentinel-2 image
 * @return {ee.Image} cloud masked Sentinel-2 image
 */
function maskS2clouds(image) {
  var qa = image.select('QA60');

  // Bits 10 and 11 are clouds and cirrus, respectively.
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;

  // 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);
}

// Map the function over one year of data and take the median.
// Load Sentinel-2 TOA reflectance data.
var dataset = ee.ImageCollection('COPERNICUS/S2')
                  .filterDate('2018-11-01', '2018-11-15')
                  // Pre-filter to get less cloudy granules.
                  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20))
                  .map(maskS2clouds);

var rgbVis = {
  min: 0.0,
  max: 0.3,
  bands: ['B11', 'B8', 'B4'],
};


Map.addLayer(dataset.median(), rgbVis, 'RGB');

Map.setCenter(74.516872, 30.475603, 14);

var aqua = ee.ImageCollection('MODIS/006/MYD14A1')
                  .filter(ee.Filter.date('2018-11-01', '2018-11-15'));
var fireMaskVis = {
  min: 9.936350984054926,
  max: 107.38312795164352,
  bands: ['MaxFRP', 'FireMask', 'FireMask'],
};

Map.addLayer(aqua, fireMaskVis, 'Fire Mask');

var terra = ee.ImageCollection('MODIS/006/MOD14A1')
                  .filter(ee.Filter.date('2018-11-01', '2018-11-15'));
var fireMaskVis = {
  min: 9.936350984054926,
  max: 107.38312795164352,
  bands: ['MaxFRP', 'FireMask', 'FireMask'],
};

Map.addLayer(terra, fireMaskVis, 'Fire Mask');

No comments:

Post a Comment