我正在尝试获取Landsat 8中几个多边形的可用图像的每个日期的平均NDVI。
尽管下面的代码似乎使我接近了,但我尝试了几种代码置换,但是ee.Reducer.mean并未在输出中添加“ mean”列。
var table = ee.FeatureCollection("users/patterletzky/Idaho_AOI"),
table2 = ee.FeatureCollection("users/patterletzky/SA_test"),
table3 = ee.FeatureCollection("users/patterletzky/ndvi_table_assest2");
//Add the area of interest (AOI)
var AOI = ee.FeatureCollection(table);
//Add the studyarea polygons into the stdyars feature collection
var stdyars = ee.FeatureCollection(table2);
// Load the LandSat 8 collection
// Filter by the Idaho AOI
var L8_clipped = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterBounds(stdyars)
.filterDate('2013-02-09', '2013-04-09')
.map(function(image){return image.clip(AOI)});
//Get the scale of the collection
var L8_scale = L8_clipped.first().projection().nominalScale();
// This function adds a band representing the image timestamp.
//var addTime = function(image) {
// return image.addBands(image.metadata('system:time_start'));
//};
// NDVI Functions for L8
function NDVI_L8(image) {
var datestr = ee.Date(image.get('system:time_start')).format('yyyy-MM-dd');
var ndvi = image.normalizedDifference(['B5', 'B4']);
//adds the band (ndvi) to the image called in the function i.e., L8mc
return ndvi.rename(datestr);
}
//Call the NDVI_L8 function
var L8mcn = L8_clipped.map(NDVI_L8);
// stack function to create one image
var stackCollection= function(collection) {
//create an initial image
var first = ee.Image(collection.first()).select([]);
//Function that appends aband to an image
var appendBands = function(image,previous) {
return ee.Image(previous).addBands(image);
};
return ee.Image(collection.iterate(appendBands,first));
};
//Run the function to name and stack ndvi bands
var ndvi_stacked = stackCollection(L8mcn);
//Obtain the mean of the polgyon region
var NDVI_final = ndvi_stacked.reduceRegions({
collection:stdyars,
reducer:ee.Reducer.mean(),
scale: L8_scale});
var exp_tble = ee.batch.Export.table.toDrive({
collection:NDVI_final,
folder:'Google EE result',
selectors:(["Studyarea","date","mean"]),
});
我想要一个具有列列研究区域,(图像的)日期,平均NDVI的表格