0

This is the link to the code. https://code.earthengine.google.com/ba342d996547c4fa8151bc99052036cf

This error message appears

This error message appears

var ColecaoL8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR');
var diltroDataL8 = ColecaoL8.filterDate('2016-01-01', '2016-12-31');
var ComposicaoL8= ee.Algorithms.Landsat.simpleComposite({
collection: diltroDataL8, asFloat: true});
Map.addLayer(ComposicaoL8 , {'bands': ['B4', 'B3', 'B2'], min: 0, max:0.3}, 'Composição Imagens Landsat 8');

var classes = urban.merge(vegetation).merge(water);

var bandas = ['B2', 'B3', 'B4', 'B5', 'B6', 'B7'];

var treinamento = ComposicaoL8.select(bandas).sampleRegions({
  collection: classes, 
  properties: ['landcover'], 
  scale: 30});

var classificar = ee.Classifier.cart().train({
  features: treinamento, 
  classProperty: 'landcover', 
  inputProperties: bandas});
//print(classificar.explain());

var classificado = ComposicaoL8.select(bandas).classify(classificar);
Map.addLayer(classificado, {min: 0, max: 2, palette: ['red', 'green', 'blue']},'Classificação');

//////////////////// VEGETAÇÃO ////////////////////
var vegetacao = classificado.select('classification').eq(1);//vegetação tem valor 1
//Map.addLayer(vegetacao);

var areaVegetacao = vegetacao.multiply(ee.Image.pixelArea()).divide(1e6);

var statVegetacao = areaVegetacao.reduceRegion ({
  reducer: ee.Reducer.sum(),
  geometry: geometry,
  scale: 30,
  maxPixels: 1e9});
print ('Área de Vegetação (km²)', statVegetacao);
2
  • Welcome to GIS SE ! Please add more context to your question, details and the complete code, if the link becomes invalid, the code will stay here and help, maybe, other people. – J. Monticolo Sep 18 '19 at 15:55
  • I hope I have satisfied your request – Felipe Hermínio Sep 18 '19 at 17:17
3

The function ee.Algorithms.Landsat.simpleComposite works on raw scenes but from what I can see you are using Landsat 8 Surface reflectance dataset. You might want to try this one instead

var ColecaoL8 = ee.ImageCollection('LANDSAT/LC08/C01/T1');
2
  • That works in raw scenes I know. But isn't there any way to use it on surface scenes? – Felipe Hermínio Sep 19 '19 at 19:41
  • Well you can't use the simpleComposite function on surface reflectance and even if we manage that it wouldn't make much sense as the function "selects a subset of scenes at each location, converts to TOA reflectance, applies the simple cloud score and takes the median of the least cloudy pixels" as mentioned here - developers.google.com/earth-engine/landsat. What you can do is, since its already surface reflectance, remove the cloudy pixels and do a median by using median function in your image collection. Ultimately what you are looking for is a composite image for 2016. – Nishanta Khanal Sep 20 '19 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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