GEE多值提取至点(多点提取栅格值)

var sample_point = ee.FeatureCollection("projects/ee/assets/sample") //上传的点矢量shp
var testregion = ee.FeatureCollection('projects/ee/assets/testregion')//掩膜的范围
var colorizedVis = {
  min: -0.8,
  max: 0.8,
  palette: ['blue', 'white', 'green'],
};

function maskS2clouds(image) {
  var qa = image.select('QA60');
  // Bits 10 and 11 are clouds and cirrus, respectively.
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;
  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
      .and(qa.bitwiseAnd(cirrusBitMask).eq(0));
  return image.updateMask(mask).divide(10000).set(image.toDictionary(image.propertyNames()));
}

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

var S2_NDVI = ee.ImageCollection("COPERNICUS/S2")
                .filterDate('2022-07-01', '2022-8-31')
                .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',20))
                .filterBounds(testregion)
                .map(maskS2clouds)
                .map(createNDVI)
                .select('NDVI').mean();
Map.addLayer(S2_NDVI, colorizedVis, 'NDVI');

// 提取像元值
var pts = ee.FeatureCollection(sample_point)

var ft1 = S2_NDVI.sampleRegions({
  collection:pts,
  properties:ee.List(["FID","lon","lat"]),
  scale:10,
  geometries:true
});
print('feature point1', ft1)

Export.table.toDrive({
  collection: ft1,
  folder:'graduate',
  description: 'S2NDVI',
  fileFormat: 'CSV',
  selectors: ["FID","lon","lat","NDVI"]
});
  • 2
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值