Validate your final land cover map

confusion matrix of the final result

step 1: add the resulting land cover map and reference data

var image = ee.Image("users/servirmekong/Vietnam/landCoverMap");
var referenceData = ee.FeatureCollection("users/servirmekong/Vietnam/ReferenceDataForestTraining");

step 2:  Take the 20% of data you didnt use for training the model

var referenceData = referenceData.randomColumn("random");
var sample = referenceData.filter("random",0.8));


step 3: Sample the land cover map

var validation = image.sampleRegions(sample,["land_class"],10);

step 4: calculate the error matrix

var confMatrix = validation.errorMatrix("land_class","Mode");
var OA = confMatrix.accuracy();
var CA = confMatrix.consumersAccuracy();
var Kappa = confMatrix.kappa();
var Order = confMatrix.order();
var PA = confMatrix.producersAccuracy();

print(confMatrix,'Confusion Matrix');
print(OA,'Overall Accuracy');
print(CA,'Consumers Accuracy');
print(PA,'Producers Accuracy');

step 5: Add the image to the map (optional)

Map.addLayer(image,{min:0,max:4,palette:"blue,purple,darkred,yellow,darkgreen"},"land cover map");<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span>



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s