GEE:生成20年NDVI动图和下载(彩色,使用MODIS数据集)

该博客展示了如何使用Google Earth Engine平台,通过MODIS数据集分析新疆和湖南地区2000年至2019年间的NDVI变化。高级版本详细演示了新疆地区的年最大NDVI影像合成及动态图制作,而初级版本则针对湖南地区进行了类似处理,但由于数据分辨率和区域大小限制,显示效果不甚清晰。博客还提到getVideoThumbURL()函数的限制,即仅支持矩形区域的动图显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

高级版本

原代码链接
https://code.earthengine.google.com/5facc53010367119130e9f19832261c9?noload=true

新疆地区2000年——2019年NDVI变化 ,效果如下图:
在这里插入图片描述

var rect = ee.Geometry.Rectangle({
  coords: [[73, 31], [99, 48]],
  geodesic: false
});
Map.addLayer(rect);
Map.centerObject(rect, 3);

// 选择影像集
var collection = ee.ImageCollection("MODIS/006/MOD13Q1")
  .filterDate('2000-01-01', '2019-01-01')
  .select('NDVI');
print(collection);
//////////////////////////////////////////////////////////
var col=ee.List([]);
for(var i=2000;i<2019;i++){
  var img=collection.filterDate(i+'-01-01',i+'-12-31');
  var img_max=img.select("NDVI").max();
  col=col.add(img_max);
}

col=ee.ImageCollection(col);
print(col,"col");

// 作为预览,加载第一幅影像
var im = ee.Image(col.first());
Map.addLayer(im, {}, "first image");

// 可视化参数
var args = {
  crs: 'EPSG:3857',  // Maps Mercator
  dimensions: '300',
  region: rect,
  min: -2000,
  max: 10000,
  palette: 'black, blanchedalmond, green, green',
  framesPerSecond: 12,
};

// 制作动图,并且加载到地图上
var thumb = ui.Thumbnail({
//为“image”指定一个集合会使图像序列产生动画效果
  image: col,
  params: args,
  style: {
    position: 'bottom-right',
    width: '320px'
  }});
Map.add(thumb);

print(col.getVideoThumbURL(args));

初级版本

https://code.earthengine.google.com/dd5c37d509aea86527613f06b7d952c1?noload=true

效果如下图

因为MODIS的分辨率比较低,而且选择的区域比较小,所以是下图看起来不太清楚的样子。当然也可以设置彩色显示。
在这里插入图片描述

var roi = ee.Geometry.Polygon(  
        [[112.51963551306746,26.815989026318352],
[112.6974766995909,26.815989026318352],
[112.6974766995909,26.931749679533954],
[112.51963551306746,26.931749679533954],
[112.51963551306746,26.815989026318352]], null, false);  

//合成20年的年最大NDVI
var sDate=ee.Date.fromYMD(2000,4,1);
var eDate=ee.Date.fromYMD(2020,4,1);

var year_list=ee.List.sequence(ee.Date(sDate).get("year"), ee.Number(ee.Date(eDate).get("year")).subtract(1));

var sss=function(num){
  var time=ee.Date.fromYMD(num, 1, 1);
  var year_image=ee.ImageCollection('MODIS/006/MOD13A1')
                  .filterDate(time,ee.Date(time).advance(1,'year'))
                  .max()
                  .clip(roi);
  var year_ndvi=year_image.select('NDVI');
      year_ndvi=year_ndvi.addBands(ee.Image.constant(num).toFloat());   
  return year_ndvi;
};

year_list=year_list.map(sss);
var img_collection=ee.ImageCollection.fromImages(year_list);

print("img_collection", img_collection);

var params = {  
    crs: 'EPSG:3857',  
    framesPerSecond: 2,  
    region: roi,  
    min: -2000,  
    max: 10000,  
    bands: ["NDVI"],  
    dimensions: 512, 
  }; 
  
print(ui.Thumbnail(img_collection, params));  
  // 使用缩略图来制作展示  
print(img_collection.getVideoThumbURL(params));

值得注意的是,getVideoThumbURL( )函数只可以显示矩形区域的动图,如果使用行政区边界切割的话,是不可以显示的。

评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_养乐多_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值