I am trying to do classification using cart. Given below is the code that was used, but I am getting 'user memory limit exceeded' error. Is there no other way to rectify this other than by reducing the extent of the ROI, randomly sampling or by knocking out a few bands? Am I doing something wrong here? This is the asset that I am using to train: https://code.earthengine.google.com/?asset=users/RohitNandakumar/train

var sent = ee.ImageCollection("COPERNICUS/S2_SR"),
    table = ee.FeatureCollection("users/RohitNandakumar/train"),
    geometry = 
    /* color: #d63000 */
    /* displayProperties: [
        "type": "rectangle"
    ] */
        [[[79.33418599339291, 29.71454696770813],
          [79.33418599339291, 29.317189386242045],
          [79.86496297093197, 29.317189386242045],
          [79.86496297093197, 29.71454696770813]]], null, false);

var land = sent.filterDate('2019-04-1','2019-11-01')
var image = ee.Image(land.toList(land.size()).get(1)).clip(geometry);
var label = 'MC_ID';
var bands = ['B2','B3','B4','B5','B6','B7','B8','B8A','B9','B11','B12']
var training = image.select(bands).sampleRegions({
  collection: table,
  properties: [label],
  scale: 10
var trained = ee.Classifier.cart().train(training, label, bands);
var classified = image.select(bands).classify(trained);

2 Answers 2


There are two problems with your code - one small and one big. For starters, you end up training your classifier on more than 500,000 training data points. That's the big problem. The second is that calling ImageCollection.toList() which isn't very efficient. Sorting this out would get your classification running.


  • Having a same problem while classifying using SVM or Random Forest. Not using large number of sample points. Any solution? Commented Feb 1, 2021 at 6:21
  • Code is working fine after changing the scale used for training. Commented Feb 1, 2021 at 6:36

For the training sample, you should use marker geometry instead of a polygon or rectangle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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