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