使用Google Earth Engine将Landsat Image Collection缩小为长格式列表时,缺少NDVI值

时间:2019-03-17 15:21:22

标签: javascript google-earth-engine

我希望将Landat时间序列的NDVI值作为要素集合,以将值导出为CSV中的长格式表。我使用了汉森全球森林变化数据集和Landsat 7时间序列。全球森林变化数据集将转换为要素集以指定关注区域。 Landsat 7时间序列用于获取随时间变化的NDVI值。

将Landat NDVI时间序列转换为要素集合后,没有NDVI值出现。将时间序列转换为三元组,仅显示“图像ID”和“ timeMillis”。 我已经检查了数据类型(现在都为int16)和投影(都为EPSG:32638)。

我将不胜感激。我有什么想念的吗?

var lossImage = ee.Image('UMD/hansen/global_forest_change_2017_v1_5')
  .select('lossyear')
  .clip(geometry);
var datamask = ee.Image('UMD/hansen/global_forest_change_2017_v1_5')
  .select('datamask')
  .clip(geometry);
// specifying int16 and EPSG equivalent to landsat
var noloss = lossImage
  .updateMask(lossImage.eq(0).and(datamask.eq(1)))
  .int16()
  .reproject('EPSG:32638', null, 30);
// create feat. collection to reduce regions of Landsat time series
var noloss_v = noloss.reduceToVectors({
  reducer: ee.Reducer.countEvery(),
  geometry: geometry,
  scale: scale
});
//// functions for Landsat
var addNDVI = function(image) {
  var ndvi = image.normalizedDifference(['B4', 'B3'])
    .rename('NDVI').int16();
  return image.addBands(ndvi);
};
var LS7 = ee.ImageCollection('LANDSAT/LE07/C01/T1_RT_TOA')
  .filterBounds(geometry)
  .filterDate('2005-01-01', '2015-12-31')
  .map(addNDVI)
  .select('NDVI');
//// Export LS NDVI 
var triplets = LS7.map(function(image) {
  return image.reduceRegions({
    collection: noloss_v.select('system:index'),
    reducer: ee.Reducer.mean().setOutputs(image.bandNames()),
    scale: 30,
  }).map(function(feature) {
    return feature.set({
      'imageID': image.id(),
      'timeMillis': image.get('system:time_start')
    });});
}).flatten();

1 个答案:

答案 0 :(得分:0)

我发现缺少的命令: 减少后,必须使用“ .filter(ee.Filter.neq('NDVI',null))”来过滤0个值

var triplets = LS7.map(function(image){
  return image.reduceRegions({
collection: noloss_v.select('system:index'),
reducer: ee.Reducer.mean().setOutputs(image.bandNames()),
scale: 30,
  }).filter(ee.Filter.neq('NDVI', null))
.map(function(feature) {
return feature.set({
  'imageID': image.id(),
  'timeMillis': image.get('system:time_start')
});
});
}).flatten();