【问题标题】:Is there any code for developing 30 years data for NDVI through landsat?是否有通过 landsat 开发 NDVI 30 年数据的代码?
【发布时间】:2019-11-27 23:54:56
【问题描述】:

这是否可以在不手动更改每一年的日期的情况下获得特定坐标的 30 年最绿像素、NDVI 年平均值和中值数据?

目前,我正在使用以下代码并手动更改年度时间范围以获取值。以及如何将这个数据集导出到.csv文件中。

var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
var spatialFiltered = l8.filterBounds(point);
print('spatialFiltered', spatialFiltered);
var temporalFiltered = spatialFiltered.filterDate('2015-01-01', '2015-12-31');
print('temporalFiltered', temporalFiltered);
var sorted = temporalFiltered.sort('CLOUD_COVER');
var scene = sorted.first();

// 获取 2015 年阴天最少的图像。

var image = ee.Image(
    l8.filterBounds(point)
        .filterDate('2015-01-01', '2015-12-31')
        .sort('CLOUD_COVER')
        .first()
);

// (NDVI).

var nir = image.select('B5');
var red = image.select('B4');
var ndvi = nir.subtract(red).divide(nir.add(red)).rename('NDVI');

//结果。

Map.centerObject(image, 9);
var ndviParams = {min: -1, max: 1, palette: ['blue', 'white', 'green']};
Map.addLayer(ndvi, ndviParams, 'NDVI image');
var ndvi = image.normalizedDifference(['B5', 'B4']).rename('NDVI');

【问题讨论】:

    标签: javascript database google-earth-engine landsat


    【解决方案1】:

    您可以使用映射函数来计算年度 NDVI 作为图像集。以下是使用 Google 地球引擎的方法。

    var point = ee.Geometry.Point([-122.44210030630455, 37.73518696319849]);
    Map.centerObject(point, 9);
    
    var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
    
    var years = ee.List.sequence(2013, 2019);
    
    var leastCloudIC = ee.ImageCollection(years.map(function (y) {
        return ee.Image(
            l8.filterBounds(point)
              .filterDate(ee.Date.fromYMD(ee.Number(y), 01, 01), 
                          ee.Date.fromYMD(ee.Number(y), 12, 31))
              .sort('CLOUD_COVER').first()
        );
    }));
    
    var annualNDVI = leastCloudIC.map(function (img) {
        return img.normalizedDifference(['B5', 'B4']).rename('NDVI').set('system:time_start', img.get('system:time_start'));
    });
    
    var ndviParams = {min: -1, max: 1, palette: ['blue', 'white', 'green']};
    var ndvi2015 = annualNDVI.filterDate('2015-01-01', '2015-12-31').first();
    Map.addLayer(annualNDVI.filterDate('2015-01-01', '2015-12-31').first(), ndviParams, 'ndvi 2015');
    

    Here's 相同的 GEE 脚本。

    【讨论】:

    • 它对我有用,但是否有任何可能的代码来计算年度中位数数据?以及如何将该数据导出到 .csv 文件中
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-18
    • 2011-04-05
    • 1970-01-01
    相关资源
    最近更新 更多