【基于Google earth engine提取水体并制作时间序列动画GIF—以Sentinel-1为例】

情景分析

  • 适用于时间序列动态变化分析中
  1. 制作时间序列Sentinel-1影像动态图
  2. 基于Sentinel-1提取水体范围及制作动态图

Sentinel-1影像动态图

利用Google earth engine云平台制作2015年—2022年时间序列的Sentinel-1 VV极化动态变化图GIF。
代码如下:

///Sentinel-1影像动态图
var Sl = ee.ImageCollection('COPERNICUS/S1_GRD').filterBounds(miyunshuiku).select(['VV']);
var distyearhb = []; 
for (var year=2015;year<2023;year++)
{ 
    print(year);
    var startDate = ee.Date.fromYMD(year, 07,01);
    var endDate = ee.Date.fromYMD(year, 10,01);
    var distyear="S1"+year
    print(distyear)
    var distyear = Sl.filterDate(startDate, endDate).mean();
    print(distyear)
    distyearhb.push(distyear)
}
print(distyearhb)
var collection=ee.ImageCollection.fromImages(distyearhb)
print(collection)
var palettes = require('users/gena/packages:palettes');
var visParams = {
  min:-25,
  max: 5,
  palette: palettes.colorbrewer.Blues[9].reverse(),
};
var rgbVis = collection.map(function(img) {
  return img.visualize(visParams).clip(miyunshuiku);
});
print(rgbVis)
// Define GIF visualization parameters.
var gifParams = {
  'region': miyunshuiku,
  'dimensions': 600,
  'crs': 'EPSG:3857',
  'framesPerSecond': 5
};
// Print the GIF URL to the console.
print(rgbVis.getVideoThumbURL(gifParams));
// Render the GIF animation in the console.
print(ui.Thumbnail(rgbVis, gifParams));

结果图如下:

在这里插入图片描述

基于Sentinel-1提取水体范围及制作动态图

代码如下:

//定义Sentinel-1水体指数SDWI计算公式
function SDWI_V1(Sen1) {
var VH = Sen1.select("VH");
var VV = Sen1.select("VV");
var x = VV.multiply(VH).multiply(10);
var y=(x).log();
var sdwi=y.subtract(8);
return sdwi;
}
//根据边界筛选数据集
var Sl = ee.ImageCollection('COPERNICUS/S1_GRD').filterBounds(miyunshuiku);
//建立一个空列表
var classifiyearhb = []; 
//循环提取2015-2022年水体面积
for (var year=2015;year<2022;year++)
{ 
    print(year);
    var startDate = ee.Date.fromYMD(year, 07,01);
    var endDate = ee.Date.fromYMD(year, 10,01);
    var distyear="S1"+year
    print(distyear)
    var distyear = Sl.filterDate(startDate, endDate).mean().clip(miyunshuiku);
    var SDWIyear="SDWI"+year
    var SDWIyear=SDWI_V1(distyear).select("VV").rename("sdwi");
    print(SDWIyear)
    // Make a FeatureCollection from the hand-made geometries.
    var polygons = ee.FeatureCollection([
      ee.Feature(water, {'class': 1}),
      ee.Feature(nowater, {'class': 0})
    ]);
    
    // Get the values for all pixels in each polygon in the training.
    var training = SDWIyear.sampleRegions({
      // Get the sample from the polygons FeatureCollection.
      collection: polygons,
      // Keep this list of properties from the polygons.
      properties: ['class'],
      // Set the scale to get Landsat pixels in the polygons.
      scale: 10
    });
    
    // Create an SVM classifier with custom parameters.
    var classifier = ee.Classifier.libsvm({
      kernelType: 'RBF',
      gamma: 0.5,
      cost: 10
    });
    
    // Train the classifier.
    var trained = classifier.train(training, 'class');
    var classifiyear="classifi"+year
    // Classify the image.
    var classifiyear = SDWIyear.classify(trained);
    classifiyearhb.push(classifiyear)
}
//建立时间序列水体提取的影像数据集并制作动态图GIF
var classificollect=ee.ImageCollection.fromImages(classifiyearhb)
var visParams = {
    min:0,
    max: 1,
    palette: ['white', 'blue']
};
var classifirgbVis = classificollect.map(function(img) {
    return img.visualize(visParams).clip(miyunshuiku);
    });
print(classifirgbVis)
// Define GIF visualization parameters.
var gifParams = {
  'region': miyunshuiku,
  'dimensions': 600,
  'crs': 'EPSG:3857',
  'framesPerSecond': 5
  };
// Print the GIF URL to the console.
print(classifirgbVis.getVideoThumbURL(gifParams));
// Render the GIF animation in the console.
print(ui.Thumbnail(classifirgbVis, gifParams));

结果图如下:
在这里插入图片描述

参考资料

[1] https://blog.csdn.net/qq_35794085/article/details/124394997
[2] https://developers.google.cn/earth-engine/tutorials/community/modis-ndvi-time-series-animation
[3] https://blog.csdn.net/qq_31988139/article/details/119949649
[4] https://blog.csdn.net/puzige/article/details/117319908
[5] https://developers.google.com/earth-engine/guides/classification

  • 2
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值