Earth Engine Python API 获取日期

Earth Engine with Python API get Date

我想从地球引擎集合的时间序列中获取日期值。这是我的代码:

import ee

ee.Authenticate()
ee.Initialize()

collection = ee.ImageCollection('NASA/FLDAS/NOAH01/C/GL/M/V001')
taken = collection.filterDate('2019-01-01', '2019-12-31').sort('system:time_start', False)
poi = ee.Geometry.Point([112.621391, -7.983908])

def setProperty(image):
    dict = image.reduceRegion(ee.Reducer.mean(), poi)
    return image.set(dict)

reduce = collection.map(setProperty)

time = reduce.aggregate_array('system:time_start').getInfo()

print(time)

但我得到了这个输出:

[378691200000, 381369600000, 383788800000, ..., 1588291200000]

问题:如何获取这样的真实日期?

2019-01-01 00:00:00

这些值是以毫秒为单位的时间戳。尝试通过以下方式将它们转换为正确的日期时间:

import datetime

time = [datetime.datetime.fromtimestamp(x/1000) for x in reduce.aggregate_array('system:time_start').getInfo()]

或者让它变短一点:

import datetime

time = reduce.aggregate_array('system:time_start').getInfo()

dt_time = [datetime.datetime.fromtimestamp(x // 1000) for x in time]

尽管我在 运行 代码中没有错误,但在我的情况下它没有显示任何内容。 就我而言,我有:

dataset = ee.ImageCollection('COPERNICUS/S2').filterDate(first_date, end_date).filterBounds(roi).filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', cloud_percentage))\
                  .map(addNDVI)\
                  .map(addMoisture)\
                  .map(maskS2clouds)\
                  .sort('system:time_start')                 
def setProperty(image):
    dict = image.reduceRegion(ee.Reducer.mean(), roi)
    return image.set(dict)

reduce = dataset.map(setProperty)

time = reduce.aggregate_array('system:time_start').getInfo()

dt_time = [datetime.datetime.fromtimestamp(x // 1000) for x in time]
print(dt_time)

我已验证在选定的时间间隔和感兴趣区域我有 35 张图像。有什么建议吗?