TransWikia.com

Invalid Number Error in Google Earth Engine?

Geographic Information Systems Asked on January 12, 2021

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
});

One Answer

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

01 is not a number. It should be 1.

Correct answer by Anatoly Sukhanov on January 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP