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 asand below are its results.
// We use ee.Filter.and() function to create a combined filter
var combinedFilter1Mangrove =Misclassified ee.Filter.and(Points
FeatureCollection ee.Filter.eq('landcover', 0),303 ee.Filter.neq('classification'elements, 0))
var mMisclassified = test.filter(combinedFilter1columns)
print('MangroveWater Misclassified Points', mMisclassified)
Points
// We useFeatureCollection ee.Filter.and() function to create989 aelements, combined0 filtercolumns)
var combinedFilter2Other =Misclassified ee.Filter.and(Points
FeatureCollection ee.Filter.eq('landcover',242 1)elements, ee.Filter.neq('classification',0 1)columns)
var wMisclassifiedAll =Misclassified test.filter(combinedFilter2)Points
print('WaterFeatureCollection Misclassified(1534 Points'elements, wMisclassified0 columns)
// We use
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 ee.Filter.andmaskS2clouds(image) function to create a combined filter
var combinedFilter3 = ee.Filter.and({
ee.Filter.eq('landcover', 2), ee.Filter.neq('classification', 2))
var oMisclassifiedqa = testimage.filterselect(combinedFilter3'QA60');
print('Other Misclassified
Points', oMisclassified)
// We can alsoBits apply10 aand filter11 toare selectclouds alland misclassifiedcirrus, pointsrespectively.
// Since we arevar comparingcloudBitMask 2= properties1 agaist<< each-other,10;
// we need to use a binary filter
var misClassifiedcirrusBitMask = test.filter(ee.Filter.notEquals({
1 leftField:'classification',<< rightField:'landcover'}))11;
print('All Misclassified Points', misClassified)
// DisplayBoth theflags misclassifiedshould pointsbe byset stylingto them
varzero, landcoverindicating =clear eeconditions.List([0, 1, 2])
var palette = ee.List(['green','blue','gray'])
var misclassStyledmask = eeqa.FeatureCollectionbitwiseAnd(
landcovercloudBitMask).map(functioneq(lc0){
var feature = misClassified.filterand(ee.Filterqa.eqbitwiseAnd('landcover', lc)cirrusBitMask)
var color = palette.get(landcover.indexOfeq(lc0));
var markerStyle = {color:color}
return feature.map(function(point){
return pointimage.setupdateMask('style', markerStyle)
})
})mask).flattendivide(10000);
Map.addLayer(misclassStyled.style({styleProperty:"style"}), {}, 'Misclassified Points')
This gave me the resultmisclassified points as follows:
Mangrove Misclassified Points
FeatureCollection (303282 elements, 0 columns)
Water Misclassified Points
FeatureCollection (989986 elements, 0 columns)
Other Misclassified Points
FeatureCollection (242269 elements, 0 columns)
All Misclassified Points
FeatureCollection (15341551 elements, 0 columns)
As you can see, so many points are gettingThe misclassified. It is because of many shadows appearing.
I looked into example, to remove the clouds and their shadows points increased, but I am findingwhen it very difficultis expected to get my head around itreduce.