Geographic Information Systems Asked by Elif Dnmz on January 5, 2021
I am running a classification code and getting different errors every time.
classification: Layer error: The service is currently unavailable.
classification: Layer error: Computation timed out.
classification: Layer error: Earth Engine capacity exceeded.
I may have too many training pixels but I remember getting results with the exact same code before, and if it is possible I don’t want to increase scale while sampling training data. How can I fix this problem?
link for my code: https://code.earthengine.google.com/6c40e833eb6fdd2bc89f8b164d3f7b3c
code itself:
// Import country boundaries feature collection.
var dataset = ee.FeatureCollection("USDOS/LSIB_SIMPLE/2017")
// Apply filter where country name equals turkey.
var turkeyBorder = dataset.filter(ee.Filter.eq('country_na', 'Turkey'));
var cloudyImage = ee.Image('COPERNICUS/S2_SR/20190427T083601_20190427T083603_T36SVJ');
// Bits 10 and 11 are clouds and cirrus, respectively.
var cloudBitMask = ee.Number(2).pow(10).int();
var cirrusBitMask = ee.Number(2).pow(11).int();
var qa = cloudyImage.select('QA60');
function maskS2clouds(image) {
var qa = image.select('QA60');
// Both flags should be set to zero, indicating clear conditions.
var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and(
qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask);
}
///august
var sent8 = ee.ImageCollection(s2
.filterDate("2019-07-27", "2019-08-03").filterBounds(turkeyBorder));
var cloudMasked8 = sent8.filterBounds(turkeyBorder).map(maskS2clouds);
var median8 = cloudMasked8.median();
///may2
var sent52 = ee.ImageCollection(s2
.filterDate("2019-05-01", "2019-05-31").filterBounds(turkeyBorder));
var cloudMasked52 = sent52.filterBounds(turkeyBorder).map(maskS2clouds);
var median52 = cloudMasked52.median();
median52 = median52.updateMask(median8)
///july
var sent7 = ee.ImageCollection(s2
.filterDate("2019-06-27", "2019-07-27").filterBounds(turkeyBorder));
var cloudMasked7 = sent7.filterBounds(turkeyBorder).map(maskS2clouds);
var median7 = cloudMasked7.median();
median7 = median7.updateMask(median8)
///june
var sent6 = ee.ImageCollection(s2
.filterDate("2019-06-01", "2019-06-30").filterBounds(turkeyBorder));
var cloudMasked6 = sent6.filterBounds(turkeyBorder).map(maskS2clouds);
var median6 = cloudMasked6.median();
median6 = median6.updateMask(median8)
var sent1 = ee.ImageCollection(s2
.filterDate("2019-10-01", "2019-11-30").filterBounds(turkeyBorder));
var cloudMasked1 = sent1.filterBounds(turkeyBorder).map(maskS2clouds);
var median1 = cloudMasked1.median();
median1 = median1.updateMask(median8)
//may
var sent5 = ee.ImageCollection(s2
.filterDate("2019-05-01", "2019-05-31").filterBounds(turkeyBorder));
var cloudMasked5 = sent5.filterBounds(turkeyBorder).map(maskS2clouds);
var median5 = cloudMasked5.median();
median5 = median5.updateMask(median8)
//yearly
var sent19 = ee.ImageCollection(s2
.filterDate("2019-01-01", "2020-01-01").filterBounds(turkeyBorder));
var cloudMasked19 = sent19.filterBounds(turkeyBorder).map(maskS2clouds);
var median19 = cloudMasked19.median();
median19 = median19.updateMask(median8)
//calculate NDVI
var med8_ndvi = median8.normalizedDifference(['B8','B4']);
var med52_ndvi = median52.normalizedDifference(['B8','B4']);
var med7_ndvi = median7.normalizedDifference(['B8','B4']);
var med1_ndvi = median1.normalizedDifference(['B8','B4']);
var med6_ndvi = median6.normalizedDifference(['B8','B4']);
//add all bands to august image
median8 = median8.addBands(med8_ndvi); //works
median8 = median8.addBands(med7_ndvi); //works
median8 = median8.addBands(med52_ndvi); //works
median8 = median8.addBands(med6_ndvi)
median8 = median8.addBands(med1_ndvi);
median8 = median8.addBands(median5);
median8 = median8.addBands(median1);
median8 = median8.addBands(median7);
//classification
var classNames =
urban_tr.merge(forest).merge(water).merge(baresoil).merge(TRARPA).merge(bugday)
.merge(ayc_tr).merge(ahashas).merge(tutun).merge(nohut_tr)
.merge(pamuk).merge(yoncaek).merge(sekerek).merge(sekerek2).merge(baresoil_col)
.merge(misir_ektr).merge(misir_ektr2).merge(bugdaydoguek).merge(forestek_tr)
.merge(patates_val).merge(hashas).merge(yonca).merge(steppe_forest_tr).merge(steppe_tr)
.merge(mercimekdogu_tr).merge(mercimekbati_tr).merge(fig_tr).merge(pamukek_tr)
.merge(bugdaydogu_tr).merge(arpasag_tr).merge(arpakuzey_tr).merge(misirbati)
.merge(misirdogu).merge(patatesbati).merge(aycbati_tr).merge(aycdogu_tr).merge(celtik_tr).merge(bugdaybati_tr).merge(baresoil2)
.merge(urbantr3).merge(sera).merge(urbantr2).merge(sera2);
var bands = [
'B1_1', 'B2_1', 'B4_1','B5_1','B6_1','B8_1','B8A_1','B9_1','B11_1',
'B1', 'B2', 'B4', 'B5', 'B6', 'B8', 'B8A', 'B9', 'B11',
'B1_2', 'B2_2','B4_2', 'B5_2','B6_2','B8_2','B8A_2','B9_2','B11_2',
'B1_3','B2_3','B4_3', 'B5_3','B6_3','B8_3','B8A_3','B9_3','B11_3',
'nd','nd_1' ,'nd_2' ,'nd_3' ,'nd_4'
];
var training = median8.select(bands).sampleRegions({
collection: classNames,
properties: ['landcover'],
scale: 10,
tileScale: 16,
geometries:true
});
//make the classifier
var classifier = ee.Classifier.svm().train({
features: training,
classProperty: 'landcover',
inputProperties: bands});
//Run the classification
var classified = median8.select(bands).classify(classifier);
//Display classification
Map.addLayer(classified,{min: 1, max: 29, palette:['#1e7419', '#0d3fb1','#594527','#c39755','#b83ef6','#c30303','#ff7938','#ffffff','#79ff69','#ffee23','#ff5ccd','#7a288e','#b5b735','#282828','#fcc87a','#8ff7fc','#8ff7fc','#27cba5','#b83ef6','#c30303','#ffee23','#ffee23','#fcc87a','#b5b735','#b5b735','#ff8eec','#b83ef6', '#7d908d','#b7edad']},'classification');
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP