2017-02-14 6 views
0

私はGoogle EarthEngine(Python APIを使用していますが、それは問題ではありません)で作業しています。私はImageCollectionを持っています。これは、コレクション内のすべての単一イメージに対してRegionごとに縮小する必要があります。Google EarthEngine:reduceRegionの時系列を取得する

EarthEngineへの1回のリクエストで.reduceRegionの時系列を取得する方法はありますか?これまでのところ、.reduceRegion( 'mean'、feature)は画像上でのみ動作することがわかりました。私はcollection.reduceRegion( 'mean'、feature)に相当するものが必要です。存在しません。すべてのタイムステップの値のリストを取得することを目標にしています。

根本的な問題は、自分の時系列を作成する際に、EE(3秒間)の要求制限に達しているということです。さらに、単一の値ごとに要求を発行するのは非常に遅いです。

コレクションに適切な還元剤を構築する方法はありますか?コレクション縮小はイメージを返す必要があるので(plsが間違っているかどうか教えてください)、私は想像することができます。所望の値を有する1つのピクセルのみを有する入力コレクション内の画像ごとに1つのバンドを有する画像を生成する。

ありがとうございました

+0

したがって、コレクションの各イメージに縮小剤の結果を含むリストが必要です。そうですか? [0.2、0.5、0.8、0.7]のようなもの? –

+0

それは正しいです。好ましくは、谷を画像に関連付ける何らかの方法で行う。しかし、私は自分自身で注文を追跡することができたと思います。 –

答えて

1

ここにアプローチがあります。 null値

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

この他のスクリプトなしであなたが辞書を取得し、このスクリプトで

は、あなたはまた、null値を取得します。このスクリプトでは-10で塗りつぶされていますが、必要に応じて変更することができます。 0または文字列にすることができます。

# -*- coding: utf-8 -*- 
""" 
Created on Tue Mar 14 11:17:29 2017 

@author: Rodrigo E. Principe 
""" 
import ee 
ee.Initialize() 

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

col = ee.ImageCollection("LANDSAT/LC8_L1T_8DAY_NDVI").filterDate("2014-01-01","2014-03-31") 

# Initial empty Dictionary 
meansIni = ee.Dictionary() 

def calcMean(img, first): 

    #gets the year of the image 
    year = img.date().format() 

    #gets the NDVI 
    nd = ee.Image(img).reduceRegion(ee.Reducer.mean(),geometry,30).get("NDVI") 

    #Checks for null values and fills them with whatever suits you (-10 is just an option) 
    ndvi = ee.Algorithms.If(ee.Algorithms.IsEqual(nd, None), -10, nd) 

    #fills the Dictionary 
    return ee.Dictionary(first).set(year, ndvi) 

# Apply calcMean() to the collection 
means = ee.Dictionary(col.iterate(calcMean, meansIni)) 

print "Dictionary of means:", means.getInfo() 
+0

ありがとうございました。まもなく評価されます。 –

関連する問題