0

Is it possible to create a classifier (e.g. CART/Random Forest) and train it on several different training images with unique sample points each using a loop or .map()?

I have successfully created a classifier in GEE and have it manually retrained on different images with their own unique labelled training points each, but since I have a large amount of data to train the classifier on, I want to automate this process and use a loop or use .map(), but this has not proven successful. I've added my snippet of code below.

var label = 'class';
var bands = ['VV', 'VH'];

// The SAR image from which the points have been selected:
var imageCol = ee.ImageCollection.fromImages([image_20220106, image_20220118, image_20220130])

// The manually selected training points selected on each image: 
var features = [points20220106, points20220118, points20220130] 
var featureCol = ee.FeatureCollection(features) 

// The training features. Selected using .sampleRegions(): 
var trainingFeatures = [training_20220106, training_20220118, training_20220130]
var trainingCol = ee.FeatureCollection(trainingFeatures)

var len = imageCol.size()
var classifier = ee.Classifier.smileCart()

for (var i=0; i < len; i++) {
    var trained = classifier.train({
      features: trainingCol.get(i), 
      classProperty: label, 
      inputProperties: bands
    })
    var classifer = trained
}
  

The aim of the classifier is to differentiate between Bragg-scattering and calm water over waterbodies.

Sunny
  • 708
  • 1
  • 4
  • 21

0 Answers0