Google 어스 엔진에서 몇 가지 다각형이 포함 된 JSON으로 Featurecollection을로드했습니다. 이 FeatureCollection에 열을 추가하여 각 다각형과 이미지 컬렉션에 포함 된 여러 이미지 각각에 대한 평균값을 제공합니다.Google 어스 엔진의 이미지 컬렉션에있는 개별 이미지의 각 밴드의 값으로 FeatureCollection 채우기
여기에 제가 지금까지 가지고있는 코드가 있습니다. 콘솔에서
//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'필드가 없거나 null입니다. 개체 : { "type": "ArgumentRef", "value": null}.
생성 된 내 CSV 파일에서 평균이라는 새 열을 얻지 만이 값은 실제 값이없는 채워집니다.