GEE下载MODIS时序数据时system:time_start非数值报错如何解决
问题解决方法
错误原因
你遇到的报错:
"Image.date: Image '5' has a 'system:time_start' property which is not a number: 2005-09-01T00:00:00"
根因是构造月均NDVI影像集合时,给system:time_start属性赋值的是ee.Date日期对象,而GEE规范要求system:time_start必须为数值类型的Unix时间戳(单位:毫秒),所以触发类型不匹配错误。
修复步骤
1. 修改月合成影像的属性赋值代码
找到你构造monthlyNDVI集合时设置system:time_start的行,给ee.Date对象调用.millis()方法转换为毫秒时间戳即可:
var monthlyNDVI = ee.ImageCollection.fromImages( years.map(function (y) { return months.map(function(m) { var monthly = ndviCollection .filter(ee.Filter.calendarRange(y, y, "year")) .filter(ee.Filter.calendarRange(m, m, "month")) .mean(); return monthly .set("year", y) .set("month", m) // 仅修改下面这行,添加.millis()将日期转为数值时间戳 .set("system:time_start", ee.Date.fromYMD(y, m, 1).millis());}); }) .flatten());
2. 可选:重投影时显式保留属性
如果修改后仍然报错,可以在重投影的map函数中显式继承原始影像的所有属性,避免处理过程中属性丢失:
var all_tiles_monthlyNDVI = monthlyNDVI.map(function(image) { return image.reproject('EPSG:4326', null, 250) // 显式拷贝原始影像的全部属性 .copyProperties(image, image.propertyNames()); });
额外优化建议
现有下载代码中循环内反复调用.toList()会增加服务端请求开销,可提前将集合转为列表后复用,降低请求超时概率。
内容的提问来源于stack exchange,提问作者Abhilash Singh Chauhan
相关产品推荐
相关产品推荐

