4

I am trying to classify my study area with a RandomForest classifier, using Sentinel-2 Surface Reflectance images. This classification gave me an accuracy of about 87%. I calculated the misclassified points and below are its results.

Mangrove Misclassified Points
FeatureCollection (303 elements, 0 columns)
Water Misclassified Points
FeatureCollection (989 elements, 0 columns)
Other Misclassified Points
FeatureCollection (242 elements, 0 columns)
All Misclassified Points
FeatureCollection (1534 elements, 0 columns)

As you can see, so many points are getting misclassified. It is because of many shadows appearing.

I looked into example, to remove the clouds and their shadows, but I am finding it very difficult to get my head around it.

I applied the below snippet

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

This gave the misclassified points as

Mangrove Misclassified Points
FeatureCollection (282 elements, 0 columns)
Water Misclassified Points
FeatureCollection (986 elements, 0 columns)
Other Misclassified Points
FeatureCollection (269 elements, 0 columns)
All Misclassified Points
FeatureCollection (1551 elements)

The misclassified points increased, when it is expected to reduce.

Please guide me in understanding how I can incorporate it into my code, to improve the accuracy and minimize the misclassification points

Here is my implementation GEE

1 Answer 1

6

I usually use the following to obtain clear sky composites:

// Generate 'clear_sky' Sentinel-2 images using SCL.
    var s2_clear_sky = function(image){
      var scl = image.select('SCL');
      var clear_sky_pixels = scl.eq(4).or(scl.eq(5)).or(scl.eq(6)).or(scl.eq(11));
      return image.updateMask(clear_sky_pixels);
    };
    
    // Map 's2_clear_sky' function over the imageCollection.
    var s2_data = s2_data.map(s2_clear_sky);

It removes 0-no data, 1-satured or defective, 2-dark area pixels, 3-cloud shadows, 7-unclassified, 8- cloud medium probability, 9-cloud high probability, 10- thin cirrus according to the SCL product: https://sentinels.copernicus.eu/web/sentinel/technical-guides/sentinel-2-msi/level-2a/algorithm

5
  • 1
    This really worked like a gem, but I wonder how to classify the white patches it has left behind on my classified image. How can I classify them into my gcps?
    – Learner
    Commented Mar 20, 2022 at 13:15
  • Try not to remove the 7-Unclassified pixels by modifying the following line: var clear_sky_pixels = scl.eq(4).or(scl.eq(5)).or(scl.eq(6)).or(scl.eq( 7)).or(scl.eq(11)). If that doesn't work, you should try to fill in the gaps with images from nearer dates. You can't classify a pixel without data. You must fill the gaps with a linear interpolation, for example. You should open another query with this.
    – sermomon
    Commented Mar 20, 2022 at 13:22
  • I tried the modification you provided, but did not work. As suggested, I will open another query regarding this. Thankyou.
    – Learner
    Commented Mar 20, 2022 at 13:44
  • I have another doubt. How can we handle the cloud cover for Landsat 8?
    – Learner
    Commented Mar 20, 2022 at 14:51
  • I'm not an expert in Landsat imagery and I have not worked with these images from GEE. But read GEE documentación: developers.google.com/earth-engine/guides/landsat
    – sermomon
    Commented Mar 20, 2022 at 17:25

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.