I am performing a supervised classification with GEE on a region in Italy and I face the error: Output of image computation is too large (15 bands for 931221 pixels = 99.5 MiB > 80.0 MiB). If this is a reduction, try specifying a larger 'tileScale' parameter.
This is the part of the code that I think makes the problem because before these lines, I did not face errors:
//Set the input image composite
var input = ee.Image(mean_Summer_IC);
//Set the band combinations
var bands = ['B1', 'B2', 'B3', 'B4','B5','B6','B7', 'B8', 'B8A', 'B9' ,'B11', 'B12','NDVI', 'EVI', /*'GNDVI',*/ 'NBR'/*, 'NDII'*/];
//Create training data
var training_Supervised = input.select(bands).sampleRegions({
collection: Training_Points,
properties: ['land_class'],
scale:10
});
//RandomForest classification approach
//Create the RF_classifier
var RF_classifier = ee.Classifier.smileRandomForest({
numberOfTrees: 500,
variablesPerSplit: 1, //null means default value. In this case the rootsquare of the number of variables
minLeafPopulation: 1,
bagFraction: 1,
maxNodes: null, //null means default value. In this case "no limits" of nodes
seed: 0,
});
//Train the classifier
var classifier01 = RF_classifier.train({
features: training_Supervised,
classProperty: 'land_class',
inputProperties: bands
});
//Run the classifier
var RF_classified = input.select(bands).classify(classifier01);
print(RF_classified);
var Palette = [
'aec3d4', // Water
'cc0013', // Residential
'cdb33b', // Agricultural
'd9903d', // Arbusti
'c3aa69', // BoschiMisti
'30eb5b', //Latifoglie
'152106', //Conifere
'f7e084' //BareSoil
];
//Show classification results
Map.addLayer(RF_classified, {min: 1, max: 8, palette: Palette},'RF_classification');
// Get a confusion matrix representing resubstitution accuracy.
print('RF error matrix: ', classifier01.confusionMatrix());
print('RF accuracy: ', classifier01.confusionMatrix().accuracy());
//Show classification results
Map.addLayer(RF_classified, {min: 1, max: 8, palette: Palette},'RF_classification');
// Get a confusion matrix representing resubstitution accuracy.
print('RF error matrix: ', classifier01.confusionMatrix());
print('RF accuracy: ', classifier01.confusionMatrix().accuracy());
What I tried to do based on the error itself was to specify a tilescale (I tried values 2, 4, 8, and 16), but it did not solve the problem. Link to my script: https://code.earthengine.google.com/578e87ba2a48ce51b2892ffbbf5cdb5c?accept_repo=users%2Fessepratico%2FPratico_et_al_RemoteSensing_2021
Is there anyway to run this script? Thanks in advance.
There are several factors that make your code heavy, including parameters for scale, amount of bands, tilescale, size of ICs etc.
I tested and was able to run your version with scale set to 120: https://code.earthengine.google.com/e18afb397b4954c6d841b7d7d5a2238a?accept_repo=users%2Fessepratico%2FPratico_et_al_RemoteSensing_2021
Also I experimented with using less bands, and was able to run at a scale of 50 without bands 1,6,7,8A.
You might want to see where you can reduce the amount of computing necessary to run the script. If you want to operate at a scale of 10 I would suggest to divide the region in smaller subsets.