map urban areas
Step 1: add your composite to the map
Map.addLayer(image,{min:0,max:3000,bands:"red,green,blue"})
Step 2: create training sample for urban
Step 3: add training samples
Step 4: create feature collection for non-urban
step 5: add points for non-urban
Step 6: merge the data points
// merge data var trainingData = urban.merge(other);
Step 7: set the prediction bands
// set the selection bands var predictionBands = image.bandNames();
Step 8: create a training sample
// sample the regions var classifierTraining = image.select(predictionBands).sampleRegions({collection: trainingData, properties: ['land_class'], scale: 30 });
Step 9: train the classifier
// train the classifier var classifier = ee.Classifier.randomForest(10).train({features:classifierTraining, classProperty:'land_class', inputProperties: predictionBands});
Step 10: Classify the image
// get the classified image var classified = image.select(predictionBands).classify(classifier);
Step 11: add the classified image to the map
Map.addLayer(classified,{min:0,max:1},"urban")
Step 12: Change the classifier to probablity
// train the classifier var classifier = ee.Classifier.randomForest(100).setOutputMode('PROBABILITY').train({features:classifierTraining, classProperty:'land_class', inputProperties: predictionBands});
Hi!
I have encountered a problem when I run the script.
Are you willing to share your solution to the problem?
https://code.earthengine.google.com/31c61172807261f633ac53fdb37c7c88
LikeLike