• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Google Earth EngineGEE合成长时序的月NDVI和LST

武飞扬头像
生态遥感监测笔记
帮助2

今天来简单分享下如何在GEE合成长时序的月NDVI与LST,并进行分析

目标:

利用MODIS为数据源,在GEE计算某一地区对月NDVI与LST,并制作统计图

以武汉市为研究区

GEE实现代码:

首先确定研究区和使用的数据集

  1.  
    var roi = ee.FeatureCollection("users/lilei655123/WUhan");
  2.  
    Map.centerObject(roi,7)
  3.  
    var styling = {color:"red",fillColor:"00000000"};
  4.  
    Map.addLayer(roi.style(styling),{},"geometry")
  5.  
    //添加MODIS植被指数16天全球250米
  6.  
    var Coll_NDVI = ee.ImageCollection("MODIS/006/MOD13Q1")
  7.  
    //MODIS/006/MOD13A1
  8.  
    var Coll_LST = ee.ImageCollection("MODIS/006/MOD11A2")
  9.  
    //MODIS/006/MOD11A1

确定起止时间和月份

  1.  
    var startYear = 2010;
  2.  
    var endYear = 2020;
  3.  
    var startDate = ee.Date.fromYMD(startYear, 1, 1);
  4.  
    var endDate = ee.Date.fromYMD(endYear, 12, 31);

合成NDVI和LST

  1.  
    Coll_NDVI = Coll_NDVI.filterDate(startDate, endDate).select("NDVI");
  2.  
    Coll_NDVI = ee.ImageCollection(ee.Algorithms.If(Coll_NDVI.size().eq(0),
  3.  
    ee.ImageCollection(ee.Image(0).selfMask().rename('NDVI')),
  4.  
    Coll_NDVI
  5.  
    ));
  6.  
    Coll_LST = Coll_LST.filterDate(startDate, endDate).select("LST_Day_1km");
  7.  
    Coll_LST = ee.ImageCollection(ee.Algorithms.If(Coll_LST.size().eq(0),
  8.  
    ee.ImageCollection(ee.Image(0).selfMask().rename('LST_Day_1km')),
  9.  
    Coll_LST
  10.  
    ));
  11.  
    // MOD12Q1数据的NDVI比例为0.0001 [ 最小值=-2000,最大值=10000]
  12.  
    var Coll_NDVI = Coll_NDVI.map(function(img) {
  13.  
    return img
  14.  
    .divide(10000).float().set("system:time_start", img.get("system:time_start")); // keep time info
  15.  
    });
  16.  
     
  17.  
     
  18.  
    var Coll_LST = Coll_LST.map(function(img) {
  19.  
    return img
  20.  
    .multiply(0.02).subtract(273.15).float().set("system:time_start", img.get("system:time_start")); // keep time info
  21.  
    });
  22.  
     
  23.  
     
  24.  
    print(Coll_NDVI);
  25.  
    print(Coll_LST);
学新通

合成月NDVI

  1.  
    var monthlyNDVI = ee.ImageCollection.fromImages(
  2.  
    years.map(function (y) {
  3.  
    return months.map(function(m) {
  4.  
    var monthly = Coll_NDVI
  5.  
    .filter(ee.Filter.calendarRange(y, y, "year"))
  6.  
    .filter(ee.Filter.calendarRange(m, m, "month"))
  7.  
    .mean();
  8.  
    return monthly
  9.  
    .set("year", y)
  10.  
    .set("month", m)
  11.  
    .set('date', ee.Date.fromYMD(y,m,1))
  12.  
    .set("system:time_start", ee.Date.fromYMD(y, m, 1));}); })
  13.  
    .flatten());
  14.  
    print('monthlyNDVI',monthlyNDVI)
  15.  
    //最大合成NDVI
  16.  
    var MonthlyMAX = ee.ImageCollection.fromImages(months
  17.  
    .map(function (m) {
  18.  
    var maxNDVI = monthlyNDVI.filter(ee.Filter.eq("month", m))
  19.  
    .reduce(ee.Reducer.percentile({percentiles: [90]}));
  20.  
    return maxNDVI
  21.  
    .set("month", m);})
  22.  
      .flatten());
  23.  
    //print (MonthlyMAX, 'MonthlyMAX');
  24.  
    Map.addLayer (MonthlyMAX.first().clip(roi), {min:0, max:1, 'palette': ['red','yellow', 'green']}, 'MonthlyMAX');
  25.  
     
  26.  
     
  27.  
    var MonthlyMIN = ee.ImageCollection.fromImages(months
  28.  
    .map(function (m) {
  29.  
    var minNDVI = monthlyNDVI.filter(ee.Filter.eq("month", m))
  30.  
    .reduce(ee.Reducer.percentile({percentiles: [10]}));
  31.  
    return minNDVI
  32.  
    .set("month", m);})
  33.  
      .flatten()); 
  34.  
    //print (MonthlyMIN, 'MonthlyMIN');
  35.  
    Map.addLayer (MonthlyMIN.first().clip(roi), {min:0, max:1, 'palette': ['red','yellow', 'green']}, 'MonthlyMIN');
学新通

同样的方法合成月LST

  1.  
    var monthlyLST = ee.ImageCollection.fromImages(
  2.  
    years.map(function (y) {
  3.  
    return months.map(function(m) {
  4.  
    var monthly = Coll_LST
  5.  
    .filter(ee.Filter.calendarRange(y, y, "year"))
  6.  
    .filter(ee.Filter.calendarRange(m, m, "month"))
  7.  
    .mean();
  8.  
    return monthly
  9.  
    .set("year", y)
  10.  
    .set("month", m)
  11.  
    .set('date', ee.Date.fromYMD(y,m,1))
  12.  
    .set("system:time_start", ee.Date.fromYMD(y, m, 1));}); })
  13.  
    .flatten());
  14.  
    print('monthlyLST',monthlyLST)
  15.  
     
  16.  
     
  17.  
     
  18.  
     
  19.  
    //最大合成LST
  20.  
    var Monthly_LST_MAX = ee.ImageCollection.fromImages(months
  21.  
    .map(function (m) {
  22.  
    var maxNDVI = monthlyLST.filter(ee.Filter.eq("month", m))
  23.  
    .reduce(ee.Reducer.percentile({percentiles: [90]}));
  24.  
    return maxNDVI
  25.  
    .set("month", m);})
  26.  
    .flatten());
  27.  
     
  28.  
    //print (Monthly_LST_MAX, 'Monthly_LST_MAX');
  29.  
    Map.addLayer (Monthly_LST_MAX.first().clip(roi), {min:15, max:35, 'palette': ['red','yellow', 'green']}, 'Monthly_LST_MAX');
  30.  
     
  31.  
     
  32.  
    var Monthly_LST_MIN = ee.ImageCollection.fromImages(months
  33.  
    .map(function (m) {
  34.  
    var minNDVI = monthlyNDVI.filter(ee.Filter.eq("month", m))
  35.  
    .reduce(ee.Reducer.percentile({percentiles: [10]}));
  36.  
    return minNDVI
  37.  
    .set("month", m);})
  38.  
    .flatten());
  39.  
     
  40.  
    //print (Monthly_LST_MIN, 'Monthly_LST_MIN');
  41.  
    Map.addLayer (Monthly_LST_MIN.first().clip(roi), {min:0, max:1, 'palette': ['red','yellow', 'green']}, 'Monthly_LST_MIN');
学新通

创建统计图

  1.  
    var ndviTimeSeries = ui.Chart.image.seriesByRegion(
  2.  
    monthlyNDVI, roi, ee.Reducer.mean(), 'NDVI', 500, 'system:time_start', 'label')
  3.  
    .setChartType('ScatterChart')
  4.  
    .setOptions({trendlines: {0: {color: 'green'}},lineWidth: 1,pointSize: 3,
  5.  
    title: 'MODIS NDVI Time Series',
  6.  
    vAxis: {title: 'NDVI'},
  7.  
    series: {
  8.  
    0: {color: 'green'},
  9.  
     
  10.  
    }});
  11.  
    print(ndviTimeSeries);
  12.  
    print(ui.Chart.image.series(monthlyNDVI , roi , ee.Reducer.mean(), 500));

运行结果如下:

学新通

LST

学新通

学新通

NDVI的带状平均值

学新通

学新通

LST的带状平均值

感谢关注,欢迎转发!

声明:仅供学习使用!

希望关注的朋友们转发,如果对你有帮助的话记得给小编点个赞或者在看

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhibafga
系列文章
更多 icon
同类精品
更多 icon
继续加载