googleeartengine:获取reduceRegion的时间序列

2024-06-08 17:06:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用googleeartingine(pythonapi,但这并不重要)。我有一个ImageCollection,我需要为集合中的每个图像按区域缩小。在

有没有一种方法可以通过对土工的单个请求来获取.reduceRegion的时间序列。到目前为止,我发现reduceRegion('mean',feature)只对图像有效。我需要一个相当于集合.还原区域('mean',feature)--不存在--目标是为每个时间步获取一个值列表。在

潜在的问题是,我在创建时间序列时遇到了EE的请求限制(每秒3次)。此外,对每个值发出请求的速度非常慢。在

有没有一种方法可以为集合构造一个适当的reducer。由于集合缩减器需要返回图像(如果不正确,请告诉我),我可以想象,例如,在输入集合中创建一个带一个带的图像,其中只有一个像素具有所需的值。在

谢谢你的帮助


Tags: 方法图像区域pythonapi目标列表时间序列
1条回答
网友
1楼 · 发布于 2024-06-08 17:06:41

这是一种方法。在

在这个脚本中,您将得到一个没有空值的字典

# -*- coding: utf-8 -*-
"""
Created on Tue Mar 14 11:21:09 2017

@author: Gennadii
"""
import ee
ee.Initialize()

geometry = ee.Geometry.Polygon([[[-71.54365539550781, -43.07340216393553],
          [-71.5484619140625, -43.11050787253287],
          [-71.488037109375, -43.125043167401266],
          [-71.48460388183594, -43.0754084526532]]])

def calcMean(img):
  # gets the mean NDVI for the area in this img
  mean = img.reduceRegion(ee.Reducer.mean(), geometry, 30).get('NDVI')

  # sets the date and the mean NDVI as a property of the image
  return img.set('date', img.date().format()).set('mean', mean)

# Applies calcMean() in the collection
col = ee.ImageCollection("LANDSAT/LC8_L1T_8DAY_NDVI").filterDate("2014-01-01","2014-03-31").map(calcMean)

# Reduces the images properties to a list of lists
values = col.reduceColumns(ee.Reducer.toList(2), ['date', 'mean']).values().get(0)

# Type casts the result into a List
lista = ee.List(values)

# Converts the list of lists to a Dictionaty
means = ee.Dictionary(lista.flatten())
print "Dictionary of means:", means.getInfo()

另一个脚本也是空值。在这个脚本中,它们是用-10填充的,但是您可以将其更改为任何需要的值。它可以是0,也可以是字符串。在

^{pr2}$

相关问题 更多 >