1

I wrote the below code for sentinel5 data, but returns Invalid Number error in monthly loop. It used to work very well but now shows error. How can I fix it?

enter image description here

code link: https://code.earthengine.google.com/7df888dfff449b1dbcb99e64d7ffc255

// study area

Map.centerObject(table);

Map.addLayer(table);


// sentinel-5 carbon monoxide

var carbon = ee.ImageCollection('COPERNICUS/S5P/NRTI/L3_CO')
.filterBounds(table)
.filterDate('2019-01-01','2019-02-01')
.select('CO_column_number_density')
.mean()
.clip(table);

Map.addLayer(carbon)

// loop monthly

var start = ee.Date.fromYMD(2018,11,01);

var months = ee.List.sequence(0,6);

var startDates = months.map(function(d){
  return start.advance(d,'month');
});

// image collection

var carbon_monthly = function(m){
  
  var start = ee.Date(m);
  var end = ee.Date(m).advance(1,'month');
  var range = ee.DateRange(start,end);
  
  var carbon = ee.ImageCollection('COPERNICUS/S5P/NRTI/L3_CO')
  .filterBounds(table)
  .filterDate(range)
  .select('CO_column_number_density')
  .map(function(img){return img.clip(table)});
  
  return carbon.mean();
  };
  
var carbon = startDates.map(carbon_monthly);

var carbon_stack = ee.ImageCollection(carbon)
.toBands();

print(carbon_stack);

Map.addLayer(carbon_stack);

Export.image.toDrive({
  image: carbon_stack,
  description: 'carbon_data',
  scale: 1000,
  region: table,
  maxPixels: 1e9
});

1 Answer 1

3

var start = ee.Date.fromYMD(2018,11,01);

01 is not a number. It should be 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.