Google Earth Engine(区域统计)

Google Earth Engine(区域统计)

提示:
在通过GEE计算遥感的地表参量以后,我们就需要对计算出来的数据进行统计。GEE上面画图的功能并不是很齐全,得到的效果也不尽如人意。因此我们就需要将GEE对区域的统计量进行导出,导入到本地以后,再进行绘图。

本期的的主要内容就是利用GEE对区域内的地表参量(如植被覆盖度、叶面积指数、蒸散量,本次以NDVI为例)进行统计(如平均值、面积等)。最后把统计的值导出到本地。


var table = ee.FeatureCollection("users/boyxiaozheng/feature/beijing");
//定义计算NDVI的函数
function cal_ndvi(image){
  var mask=ee.Algorithms.Landsat.simpleCloudScore(image).select(['cloud']).lte(20);
  var ndvi=image.normalizedDifference(['B5', 'B4']).updateMask(mask);
  return ndvi;
}
//设置开始时间
var start_time=ee.Date('2014-01-01')
//初始化列表,存储统计的值
var data_list=[]
for (var index = 0;index< 4; index++){
  var temp_image= ee.ImageCollection("LANDSAT/LC08/C01/T1_RT")
  .filterBounds(table.geometry())
  .filter(ee.Filter.lt('CLOUD_COVER',10))
  //根据循环的index依次筛选四个季度的Landsat-8数据
.filterDate(ee.Date(start_time).advance(index*3,'month'),ee.Date(start_time).advance((index+1)*3,'month'))
  .map(cal_ndvi)
  .mean();
  //对每个季度的影像进行求平均
  var meanDictionary = temp_image.reduceRegion({
//可以设置成maxmin或count(像元个数)
  reducer: ee.Reducer.mean(),
  geometry: table.geometry(),
  scale: 30,
  maxPixels: 1e9
  });
  //把统计量存成Feature,并记录开始时间和结束时间
  var temp_feature=ee.Feature(null,meanDictionary);
  temp_feature = temp_feature.set('satr_time', ee.Date(start_time).advance(index*3,'month'));
  temp_feature = temp_feature.set('end_time', ee.Date(start_time).advance((index+1)*3,'month'));
  data_list.push(temp_feature)

}
//把存储Feature的列表转成FeatureCollection
var featureCollection = ee.FeatureCollection(data_list);
//把数据存到谷歌云盘上面
Export.table.toDrive({
  collection: featureCollection,
  description: 'exportTableExample',
  fileFormat: 'CSV'
});
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值