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?
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
});
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
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP