GEE学习笔记3:Landsat8 植被指数计算

一、Landsat8 植被指数计算

从GEE数据集导入的数据

在这里插入图片描述

 // NDVI
    function L8_ndvi(image){
       return image.addBands(image.normalizedDifference(['B5', 'B4']).rename("L8_NDVI"));
    }
    
    // RVI
    function L8_rvi(image){
      
        var rvi = image.expression('NIR / Red', {
        'NIR': image.select('B5'),
        'Red': image.select('B4')
        }).float();
        return image.addBands(rvi.rename('L8_RVI'));
    }
    //EVI
    function L8_evi(image){
         var evi = image.expression('2.5 * ((NIR - RED) / (NIR + 6 * RED - 7.5 * BLUE + 1))', {
        'NIR' : image.select('B5'),
        'RED' : image.select('B4'),
        'BLUE': image.select('B2')
      }).float();
      return image.addBands(evi.rename('L8_EVI'));
    }
    
    //DVI
    function L8_dvi(image){
         var dvi = image.expression('NIR - Red', {
        'NIR': image.select('B5'),
        'Red': image.select('B4')
      }).float();
      return image.addBands(dvi.rename('L8_DVI'));
    }
    
    //NDWI
    function L8_ndwi(image){
      
       return image.addBands(image.normalizedDifference(['B3', 'B5']).rename("L8_NDWI"));
    }
      
    // NDBI
    function L8_ndbi(image){
        return image.addBands(image.normalizedDifference(['B6', 'B5']).rename("L8_NDBI"));
    }
    
    
    function L8_savi(image) {
      // Add Soil Adjust Vegetation Index (SAVI)
        // using L = 0.5;
        var savi = image.expression('(NIR - RED) * (1 + 0.5)/(NIR + RED + 0.5)', {
        'NIR': image.select('B5'),
        'RED': image.select('B4')
        }).float();
        return image.addBands(savi.rename('L8_SAVI'));
    }
     
     
    function L8_ibi(image) {
      // Add Index-Based Built-Up Index (IBI)
      var ibiA = image.expression('2 * SWIR1 / (SWIR1 + NIR)', {
        'SWIR1': image.select('B6'),
        'NIR'  : image.select('B5')
      }).rename(['IBI_A']);
     
      var ibiB = image.expression('(NIR / (NIR + RED)) + (GREEN / (GREEN + SWIR1))', {
        'NIR'  : image.select('B5'),
        'RED'  : image.select('B4'),
        'GREEN': image.select('B3'),
        'SWIR1': image.select('B6')
      }).rename(['IBI_B']);
     
      var ibiAB = ibiA.addBands(ibiB);
      var ibi = ibiAB.normalizedDifference(['IBI_A', 'IBI_B']);
      return image.addBands(ibi.rename(['L8_IBI']));
    }



    

加载Landsat 8

    //去云 
    function maskL8sr(image) {
      var cloudShadowBitMask = (1 << 3);
      var cloudsBitMask = (1 << 5);
      var qa = image.select('pixel_qa');
      var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
                    .and(qa.bitwiseAnd(cloudsBitMask).eq(0));
      return image.updateMask(mask);
    }
    //L8为从GEE 数据集导入的Landsat 8数据
    var landsat8Image =L8.filterBounds(roi)
                        .filterDate(startdate, enddate)
                        .map(maskL8sr)
                        .map(L8_ndvi)
                        .map(L8_rvi)
                        .map(L8_evi)
                        .map(L8_dvi)
                        .map(L8_ndwi)
                        .map(L8_ndbi)
                        .map(L8_savi)
                        .map(L8_ibi)
                        .median();

你可能感兴趣的:(GEE,GEE,Landsat8,植被指数)