Springe direkt zu Inhalt

Classification

Classification - Classification and Regression Trees (CART)

The only thing left now is to actually train the classifier with our training data.
GEE offers various training methods, like for example CART (Classification and Regression Trees)- or Random Forest-Classifiers. Make sure to check out the documentation to find out more about their syntax!

Let us start with a simple CART-Classifier.

//Example CART Classifier:
var cartclassifier = ee.Classifier.smileCart().train({
  features: training,
  classProperty: 'landcover'
});


//Run the classification
var cartclassified = s2a_median.classify(cartclassifier);

//Display classification
Map.addLayer(cartclassified,
{min: 0, max: 3, palette: ['blue', 'green', 'orange','yellow']},
'CART classification');

Classification - Random Forest

In a very similar fashion, we can easily adjust our code to use a Random Forest classifier.

//Example RandomForest Classifier:
var rfclassifier = ee.Classifier.smileRandomForest(50).train({
  features: training,
  classProperty: 'landcover'
});


//Run the classification
var rfclassified = s2a_median.classify(rfclassifier);

//Display classification
Map.addLayer(rfclassified,
{min: 0, max: 3, palette: ['blue', 'green', 'orange','yellow']},
'RF classification');