google 地球引擎:ee.List() 输出为整数?

google earth engine: ee.List() output as an integer?

我可以不 JSON.stringify() ee.List() 的输出吗?

var dates = ee.List(imageCollection.get('date_range'));
print('type: ', typeof(dates));
print('JSON.stringify: ', JSON.stringify(dates));

print('Date zero: ', dates.get(0));
print('type: ', typeof(dates.get(0)))
print('JSON.stringify: ', JSON.stringify(dates.get(0)))

控制台显示:

type: 
object
JSON.stringify: 
{} 

Date zero: 
1365638400000
type: 
object
JSON.stringify: 
{}  

我的最终目标是将 dates.get(0) 解释为整数....

那些是服务器对象。您必须请求它们的值(使用同步 getInfo() 或异步 evaluate())来混合和匹配客户端函数,例如 JSON.stringify():

var dates = ee.List(imageCollection.get('date_range'));
print('type: ', typeof(dates));
print('JSON.stringify: ', JSON.stringify(dates.getInfo()));

print('Date zero: ', dates.get(0));
print('type: ', typeof(dates.get(0)))
print('JSON.stringify: ', JSON.stringify(dates.get(0).getInfo()))

请注意,此时无需对任何内容进行字符串化。即 dates.get(0).getInfo()Number:

print('A number: ', Number(dates.get(0).getInfo()))