Python Google EarthEngine:reduceRegion()的时间序列

Python Google EarthEngine:reduceRegion()的时间序列,python,google-earth-engine,Python,Google Earth Engine,我正在使用Google Earthine Python API。我有一个图像采集系统(MODIS),希望提取一个时间序列,其中包含每个时间步长的区域平均NDVI 目前,我正在迭代单个图像并提取每个图像的值。像 feature_geometry = { 'type': 'MultiPolygon', 'coordinates': [[[ [-120, 35], [-120.001, 35], [-120.001, 35.001],

我正在使用Google Earthine 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'])

问题:有没有一种方法可以在对EartEngine的单个请求中获得相同的结果,因为我往往会遇到请求限制。

下面是一个我认为您在问的问题的示例:

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()

下面是一个我认为你在问的问题的例子:

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()

到目前为止的想法:a)是否有一种方法可以使用ImageCollection.reduce()?,b)创建一个带时间步长的图像,然后在其上运行image.reduceRegion()。不会将其称为重复图像,但这可能是一个开始。将在本周晚些时候进行评估。福尔克:你说得对。让我设计一个python解决方案。到目前为止的想法是:a)有没有办法以某种方式使用ImageCollection.reduce()?,b)创建一个带时间步长的图像,然后在其上运行image.reduceRegion()。不会将其称为重复,但这可能是一个开始。将在本周晚些时候进行评估。福尔克:你说得对。让我来设计一个python解决方案。非常感谢,效果非常好。有没有简单的方法将图像id添加到返回中?我现在正想弄明白。好的,明白了。我只需要使用mean.getInfo()并遍历这个巨大的字典。您可以从图像集合的属性中获取任何内容的数组。请注意,
aggregate\u array()
reduce(ee.Reducer.toList(),…)
的快捷方式,后者产生了更明确的map reduce习惯用法。非常感谢,这非常有效。有没有简单的方法将图像id添加到返回中?我现在正想弄明白。好的,明白了。我只需要使用mean.getInfo()并遍历这个巨大的字典。您可以从图像集合的属性中获取任何内容的数组。请注意,
aggregate\u array()
reduce(ee.Reducer.toList(),…)
的快捷方式,后者产生了更明确的map reduce习惯用法。