1

I'm using Landsat 8 in Google Earth Engine to detect the water body in Jiangsu and Zhejiang area, China.

The formula is:

mNDWI = (Green-SWIR)/(Green+SWIR)

I applied this formula to GEE code, and it shows as follow:

enter image description here

As we can see, the blue area corresponds to the land, while the red area corresponds to the water body. The coastal line is clearly and correctly displayed. However, that only works for the shallow water area: As the distance to the coast increases, the red color fades away and the deep water area shows in blue.

The EVI result has the similar issue, I applied the formula:

EVI = 2.5*(NIR-RED)/(NIR+6*RED-7.5*BLUE+1)

And it shows as follow:

enter image description here

I promise that can't be cloud or some other disturb factors, I have already removed them before computing the indices. The shape of the abnormally displayed area is highly related to the shape of shallow water area, as shown below as a kind of yellow water:

enter image description here

I will also share my code here, hope anyone could figure out why it occurs, or is there any mistake I made, and how can I make the deep water area shown as what it should be.

//Choose Area
var region = ee.Geometry.Polygon({
  coords: [[[119.65, 36.28], [125.08, 30.63], [119.56, 29.65],[118.07, 33.81]]],
  geodesic: false
});


//Add image collection
var landsat8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR');

// Fmask classification values var FMASK_CLEAR_GROUND = 0; var FMASK_WATER = 2; var FMASK_CLOUD_SHADOW = 3; var FMASK_SNOW = 4; var FMASK_CLOUD = 5;

var non_mosaic = landsat8 .filterBounds(region) .filterDate('2017-01-01', '2017-12-31');

var getQABits = function(image, start, end, newName) {
    // Compute the bits we need to extract.
    var pattern = 0;
    for (var i = start; i <= end; i++) {
       pattern += Math.pow(2, i);
    }
    // Return a single band image of the extracted QA bits, giving the band
    // a new name.
    return image.select([0], [newName])
                  .bitwiseAnd(pattern)
                  .rightShift(start);
};

// A function to mask out cloudy shadow pixels.
var cloud_shadows = function(image) {
  // Select the QA band.
  var QA = image.select(['pixel_qa']);
  // Get the internal_cloud_algorithm_flag bit.
  return getQABits(QA, 3,3, 'Cloud_shadows').eq(0);
  // Return an image masking out cloudy areas.
};

// A function to mask out cloud pixels.
var clouds = function(image) {
  // Select the QA band.
  var QA = image.select(['pixel_qa']);
  // Get the internal_cloud_algorithm_flag bit.
  return getQABits(QA, 5,5, 'Cloud').eq(0);
  // Return an image masking out cloudy areas.
};

var maskClouds = function(image) {
  var cs = cloud_shadows(image);
  var c = clouds(image);
  image = image.updateMask(cs);
  return image.updateMask(c);
};

//Will be used for frequency calculaton
var clouds_free = non_mosaic.map(maskClouds);

//display the mosaicked origional image and cloud free image
var mosaic_free = non_mosaic.map(maskClouds).median();
var visParams = {bands: ['B4', 'B3', 'B2'],min: [0,0,0],max: [2000, 2000, 2000]};
Map.setCenter(121.07, 33.02, 6);
Map.addLayer(mosaic_free, visParams, 'Cloud free'); 

//The index results on a single day (Dec 31st 2017) are shown below

// Display the mNDWI.
// Define the visualization parameters.
var vizParams = {bands: ['B6', 'B5', 'B2'], min: 0, max: 0.5,gamma: [0.95, 1.1, 1]};
// Create an mNDWI image, define visualization parameters and display.
var mndwi = mosaic_free.normalizedDifference(['B3', 'B6']);
var mndwiViz = {min: 0, max: 1, palette: ['0000FF', 'FF0000']};
Map.addLayer(mndwi, mndwiViz, 'mNDWI');

// Display the EVI.
// Define the visualization parameters.
var vizParams = {bands: ['B6', 'B5', 'B2'], min: 0, max: 0.5,gamma: [0.95, 1.1, 1]};
// Create an EVI image, define visualization parameters and display.
var evi = mosaic_free.expression(
    '(NIR - RED)/(NIR+6*RED-7.5*BLUE+1)*2.5', {
      'BLUE': mosaic_free.select('B2'),
      'RED': mosaic_free.select('B4'),
      'NIR': mosaic_free.select('B5'),
});
var eviViz = {min: 0, max: 1, palette: ['0000FF', 'FF0000']};
Map.addLayer(evi, eviViz, 'EVI');
0

I found another index: AWEI. It works better.

The formula is BLUE+2.5*GREEN-1.5*(NIR+SWIR1)-0.25*SWIR2.

The threshold of "equal to or larger than 0" gives a good result.

However, to be more accurate and serious, a Otsu optimization is needed.

Your Answer

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

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