TransWikia.com

Classification: Layer error: Classifier training failed: 'Only one class.'

Geographic Information Systems Asked on December 8, 2021

i am new in GEE and try a tutorial from this https://www.gears-lab.com/intro_rs_lab4/ but the result show error classifier training failed: ‘Only one class.’. So i try to fix it and combine with this tutorial https://developers.google.com/earth-engine/classification but again the result show error training failed: ‘Only one class

this is my code https://code.earthengine.google.com/5412d64d8ba217f879be98f6ba491146
im stuck.

sorry my bad english.

One Answer

var classifier = ee.Classifier.smileCart().train(training, 'landcover', bands);

You're telling the classifier to learn to classify points according to the value of the 'landcover' property. But in all of your input data, the value of landcover is always 0, so there is only one class, 0. This is reported as an error because a classification with one class is not useful — it gives no information.

To fix this, in the geometry list, click on the gear icon for each of your point sets:

Geometry Imports list

Then in the "Configure geometry imports" dialog, give each one a different number for the landcover property. I edited them so that urban is 0, forest is 1, agriculture is 2, and water is 3.

Property list in dialog

After you do this, the script will run without error and your classifier will be trained successfully. Then you'll want to view the results. Here's how to do that with a palette set up to match your marker colors:

Map.addLayer(classified, {min: 0, max: 3, palette: ['red', 'blue', 'green', 'cyan']});

Here is your script with those two modifications (property value in the geometry imports, and Map.addLayer in use).

Answered by Kevin Reid on December 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP