ここにアプローチがあります。 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.2、0.5、0.8、0.7]のようなもの? –
それは正しいです。好ましくは、谷を画像に関連付ける何らかの方法で行う。しかし、私は自分自身で注文を追跡することができたと思います。 –