1

I tried creating a classification training data but I keep getting an error "FeatureCollection (Error) Collection query aborted after accumulating over 5000 elements." Below is the code; how can I solve this?

//Training Data
var training_data = Forest.merge(Agriculture).merge(Water).merge(Urban).merge(Bareland);
print('Training Data',training_data);

//Prediction Bands Landsat
var predictBands_l8 = ['B','G','R','NIR','SWIR1','SWIR2','QA_PIXEL'];

//Prediction Bands Sentinel
var predictBands_s2 = ['B','G','R','NIR','SWIR1','SWIR2','QA60'];

//Classifier Training Landsat
var classifierTraining_l8 = lsat8.select(predictBands_l8)
                                 .sampleRegions({
                                   collection: training_data,
                                   properties: ['class'],
                                   scale: 10
                                 });
print('Classifier Training Landsat', classifierTraining_l8);

//Classifier Training Sentinel
var classifierTraining_s2 = sent2.select(predictBands_s2)
                                 .sampleRegions({
                                   collection: training_data,
                                   properties: ['class'],
                                   scale: 10
                                 });
print('Classifier Training Sentinel', classifierTraining_s2);

1 Answer 1

1

You can't use print() (or a few other things, like .toList()) on a collection containing over 5000 elements.

That doesn't mean you can't use the collection for other operations, though — just don't try to print it entirely (you can print a part of it, or its size).

If you did not intend to produce that many points in your training collection, in which case you should change the scale of your sampleRegions() to be higher than 10 meters.

1

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.