我正在使用 Google EarthEngine Python API。我有一个图像集 (MODIS),我想提取一个时间序列,其中包含每个时间步长的某个区域的平均 NDVI。
目前,我正在迭代单个图像并提取每个图像的值。喜欢
feature_geometry = {
'type': 'MultiPolygon',
'coordinates': [[[
[-120, 35],
[-120.001, 35],
[-120.001, 35.001],
[-120, 35.001],
[-120, 35]
]]]
}
ee.Initialize()
feature = ee.Feature(feature_geometry)
collection = ee.ImageCollection(
'MODIS/006/MOD13Q1').filterDate('2017-01-01', '2017-05-01')
images = [
item.get('id') for item in collection.getInfo().get('features')]
for image in images:
print(ee.Image(image).reduceRegion(
ee.Reducer.mean(), feature.geometry()).getInfo()['NDVI'])
问题:有没有办法在对 EarthEngine 的单个请求中获得相同的结果,因为我往往会遇到请求限制。
请您参考如下方法:
这是我认为您要问的示例:
import ee
ee.Initialize()
feature_geometry = {
'type': 'MultiPolygon',
'coordinates': [[[
[-120, 35],
[-120.001, 35],
[-120.001, 35.001],
[-120, 35.001],
[-120, 35]
]]]
}
collection = ee.ImageCollection(
'MODIS/006/MOD13Q1').filterDate('2017-01-01', '2017-05-01')
def setProperty(image):
dict = image.reduceRegion(ee.Reducer.mean(), feature_geometry)
return image.set(dict)
withMean = collection.map(setProperty)
print withMean.aggregate_array('NDVI').getInfo()
