GEE学习笔记三 利用GEE获取矢量点处的NDVI值

我们可以利用GEE获取一块研究区的NDVI值,那么我们如何利用GEE获取单个或者一定数量的矢量点处的NDVI值呢?

本文演示利用GEE获取矢量点处的NDVI值,其中本文获取的NDVI为Sentinel2数据获取的NDVI,获取Landsat影像的NDVI代码可见博主历史笔记利用GEE获取Sentinel-2与Landsat8影像NDVI

var geometry = ee.FeatureCollection("users/huiengine/Shandong_Boundary")
//在区域内生成随机样本点
var points = ee.FeatureCollection("users/huiengine/ShanDong_ST2020")
print(points,"points");
Map.addLayer(points, {}, "Points" , true);
Map.addLayer(geometry, {}, "shandong" , true);
 
 
 
//sentinel数据去云  
function maskS2clouds(image) {
  var qa = image.select('QA60');
  // 第10和11位分别是云和卷云。位移运算去云
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;
  // 这两个标志都应设为零,表示条件明确。
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
      .and(qa.bitwiseAnd(cirrusBitMask).eq(0));
  return image.updateMask(mask).divide(10000);
}
 

function NDVI_Sentinel2(image){
  var ndvi = image.normalizedDifference(["B8","B4"]).rename('NDVI');
  return image.addBands(ndvi.rename('NDVI'));
}
 

 
  var scol= ee.ImageCollection("COPERNICUS/S2")
          .filterBounds(geometry)
          .filterDate('2020-04-01', '2020-05-15')
          .map(maskS2clouds)
          .map(NDVI_Sentinel2)
          
          
;
print("scol",scol);
  var ndvi_before =scol.qualityMosaic('NDVI').clip(points);
print("ndvi_before",ndvi_before);
 
// 值提取至点
var samples = ndvi_before.select("NDVI").sampleRegions({
  collection: points,
  scale: 30 ,
  geometries: true
});
print(samples,'samples');
Map.addLayer(samples,{}, "samples" , false);
 
print(" ndvi value ", samples);
 
 
//导出逐年NDVI个点的CSV文件
Export.table.toDrive({
  collection: samples,
  description:'shandong_ST',
  folder:"shandong",
 
});
 


将结果导入到Google drive下载后即可得到矢量点处的NDVI值数据
样本点分布
样本点分布图
矢量点处的NDVI值
矢量点处的NDVI值

  • 5
    点赞
  • 65
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值