1

I set up a script for supervised following the model from the EE tutorial -- Only thing I changed was to substitute Landsat 5 with Sentinel 2. The classifier does not give me any result -- Any idea why or how to fix it?

var point = ee.Geometry.Point([18.31, 20.85]);
var s2 = s2toa.filterBounds(point) //filter all scenes using point geometry from above (i.e. limit to Friuli)
  .sort('CLOUDY_PIXEL_PERCENTAGE', true).limit(300);
var s2Time1 = s2.select('B[2-8]');
var input = ee.Image(s2Time1.first()).clip(studysite);
print(input)
Map.centerObject(studysite, 10);
Map.addLayer(input, {
  min: 750,
  max: 2100,
  bands: ['B8', 'B3', 'B2']
}, 'input image');
var training = basalt_train.merge(Sand_train);
var training = input.sampleRegions({
  collection: training,
  properties: ['class'],
  scale: 30
});
var classifier = ee.Classifier.smileRandomForest(100).train(training, 'nd'); //set the number of trees in random forest to 100
var classified = input.classify(classifier);
print(classified)
Map.addLayer(classified, {
  min: 0,
  max: 1
}, 'classified image');

https://code.earthengine.google.com/751ac9cfdb5c33ad5790bf69bae87003

1
  • 1
    Welcome to GIS SE. As a new user, please take the Tour. Coding questions are expected to contain a relevant code fragment which reproduces the problem. A link to another site is not sufficient. – Vince May 14 '20 at 11:44
0

You have specified a non-existing classProperty in train(). Update it to class, and your code works.

var classifier = ee.Classifier.smileRandomForest(100).train(training, 'class'); //set 

https://code.earthengine.google.com/6d425e23cef110a1a97e7aac6fcd8ebb

1
  • Thank's very much for the help! Carla. – geo gravity May 14 '20 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.