2017-12-08 5 views
0

Google Earth Engineでは、多少のポリゴンを含むJSONとしてFeaturecollectionにロードしました。このFeatureCollectionに列を追加して、各ポリゴンとイメージコレクション内に含まれる複数のイメージそれぞれの2つのバンドの平均値を取得します。FeatureCollectionにGoogle Earth Engineの画像コレクション内の各画像のバンドの値を設定する

これまでのコードは次のとおりです。私は、エラーメッセージ

要素(エラー) を取得コンソールで

//Polygons 

var polygons = ee.FeatureCollection('ft:1_z8-9NMZnJie34pXG6l-3StxlcwSKSTJFfVbrdBA'); 

Map.addLayer(polygons); 

//Date of interest 

var start = ee.Date('2008-01-01'); 
var finish = ee.Date('2010-12-31'); 

//IMPORT Landsat IMAGEs 
var Landsat = ee.ImageCollection('LANDSAT/LT05/C01/T1') //Landsat images 
.filterBounds(polygons) 
.filterDate(start,finish) 
.select('B4','B3'); 

//Add ImageCollection to Map 
Map.addLayer(Landsat); 

//Map the function over the collection and display the result 
print(Landsat); 

// Empty Collection to fill 
var ft = ee.FeatureCollection(ee.List([])) 

var fill = function(img, ini) { 
    // type cast 
    var inift = ee.FeatureCollection(ini) 

    // gets the values for the points in the current img 
    var mean = img.reduceRegions({ 
    collection:polygons, 
    reducer: ee.Reducer.mean(), 
}); 

// Print the first feature, to illustrate the result. 
print(ee.Feature(mean.first()).select(img.bandNames())); 

    // writes the mean in each feature 
    var ft2 = polygons.map(function(f){return f.set("mean", mean)}) 

    // merges the FeatureCollections 
    return inift.merge(ft2) 

    // gets the date of the img 
    var date = img.date().format() 

    // writes the date in each feature 
    var ft3 = polygons.map(function(f){return f.set("date", date)}) 

    // merges the FeatureCollections 
    return inift.merge(ft3) 
} 

// Iterates over the ImageCollection 
var newft = ee.FeatureCollection(Landsat.iterate(fill, ft)) 

// Export 
Export.table.toDrive(newft, 
"anyDescription", 
"anyFolder", 
"test") 

JSONをデコードするのに失敗しました。 エラー:オブジェクト '{"type": "ArgumentRef"、 "value":null}'のフィールド 'value'がありません。 オブジェクト:{"type": "ArgumentRef"、 "value":null}

私のCSVファイルには、平均と呼ばれる新しい列がありますが、これには実際の値は設定されていません。

答えて

0

ここでiterate()を使用する理由はありません。あなたができることは入れ子になったmap()です。ポリゴンをオーバーしてからイメージをオーバーします。あなたは、このような1つのリストにそれを回すためにリストの結果のリストを平らにすることができます

// compute mean band values by mapping over polygons and then over images 
var results = polygons.map(function(f) { 
    return images.map(function(i) { 
    var mean = i.reduceRegion({ 
     geometry: f.geometry(), 
     reducer: ee.Reducer.mean(), 
    }); 

    return f.setMulti(mean).set({date: i.date()}) 
    }) 
}) 

// flatten 
results = results.flatten() 

スクリプト:同じアプローチは、マッピング画像の上に、その後、同様reduceRegions()で使用することができますhttps://code.earthengine.google.com/b65a731c78f78a6f9e08300dcf552dff

地域を超えてただし、日付を設定するために結果のフィーチャをマップする必要があります。

images.filterBounds(f)あなたの機能がより広い領域をカバーする場合は、おそらく追加することもできます。

PS:あなたのテーブルは共有されていません

関連する問題