1

I am trying to classify my image using SVM classifier in Google Earth Engine, but I am getting an error (Computation Timeout)

var data= L8SR1.filterDate('2019-02-01', '2019-03-28') 
              .filter(ee.Filter.equals('WRS_PATH', 146))
              .filter(ee.Filter.eq('WRS_ROW', 40))
              .sort('CLOUD_COVER').first();
//Get cloud cover information
var cloud= data.get('CLOUD_COVER');
//Cip with boundary
var Study_region = data.clipToCollection(aoi);
// Define the visualization parameters.
var colour = {bands: ['B5', 'B4', 'B3'],min: 0,max: 5000,gamma: 1.4,}
// Add layer to the map
Map.addLayer(Study_region,colour,'FCC');
Map.centerObject(aoi, 9);
var select_band =Study_region.select('B2','B3', 'B4', 'B5', 'B6', 'B7');

//Feature collection and classification
var sample = Urban_S.merge(Sub_urb_S).merge(Veg_S).merge(Water_S)
            .merge(Rock_S).merge(Barren_land_S).merge(Dense_veg_S);
var training = Study_region.sampleRegions({
  collection: sample, 
  properties: ['LC'], 
  scale: 30
});
var classifier = ee.Classifier.svm().train(training,"LC")
var classified = Study_region.classify(classifier);
Map.addLayer(classified, {min: 1, max: 8, palette: [ '#FFFFFF','#808080','#000000',
'#FF0000', '#800000', '#FFFF00', '#008000', '#00FFFF']}, 'classification');
//Urban extraction
var urban = classified.lte(2);
var urban_Mask = urban.mask(urban.neq(0))
//Map.addLayer(urban, {min: 0, max: 1, palette: [ '#FFFFFF','#808080']},'urban');
//Area calulation
var Urban_area = urban.multiply(ee.Image.pixelArea()).divide(1000 * 1000)
.reduceRegion({
  reducer: ee.Reducer.sum(),
  geometry: aoi,
  scale: 30,
  maxPixels: 1e9
});
print('Urban_area',Urban_area);//area in sq. km

And I am trying to extract the urban class i.e 1 and 2 in my sampels, and calculate the area of it.

check my code here

Prathiba
  • 11
  • 2

1 Answers1

1

I ran your code with slight modification and it worked.

Replaced ".clipToCollection(aoi)" with ".clip(aoi)" and increased the scale for both training and classified. Hope it will help a bit. https://code.earthengine.google.com/53e6d8f37b94f0a164753b02e8b45c5b

  • I also like to know, I selected polygons samples for training and how the values of multiple pixels inside the polygon will be used for training? What type of statistics it uses, either mean or median? – Prathiba Sep 28 '20 at 16:53