GEE:获取sentinel2指定区域多个单景影像的值(样本点提取)
  u6lSrlpjxquL 2023年11月02日 31 0


简介

本教程的主要目的是获取指定单景影像,然后获取指定波段的影像值,按照获取指定波段的影像进行值提取至点,因为这里暂时没有好的方法对哨兵数据的具体属性值进行提取,所以在筛选哨兵影像的时候,需要手动获取每一景影像的id,然后按照单一影像多波段的组合来实现整体的值提取至点,这里的需要提前准备好你所需提取的矢量数据集合.

函数

reduceRegions(collection, reducer, scalecrscrsTransformtileScale)

Apply a reducer over the area of each feature in the given collection.

The reducer must have the same number of inputs as the input image has bands.

Returns the input features, each augmented with the corresponding reducer outputs.

Arguments:

this:image (Image):

The image to reduce.

collection (FeatureCollection):

The features to reduce over.

reducer (Reducer):

The reducer to apply.

scale (Float, default: null):

A nominal scale in meters of the projection to work in.

crs (Projection, default: null):

The projection to work in. If unspecified, the projection of the image's first band is used. If specified in addition to scale, rescaled to the specified scale.

crsTransform (List, default: null):

The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with 'scale', and will replace any transform already set on the projection.

tileScale (Float, default: 1):

A scaling factor used to reduce aggregation tile size; using a larger tileScale (e.g. 2 or 4) may enable computations that run out of memory with the default.

Returns: FeatureCollection

需要获取的单景影像名称

GEE:获取sentinel2指定区域多个单景影像的值(样本点提取)_值提取至点

代码:

var training = ee.FeatureCollection("projects/ee-bqt2000204051/assets/classfication_tree-points")
print("training trree",training)


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);
}


function renameS2_SR(img) {
  return img.select(
		["B2",  "B3",  "B4",  "B8",  "B11",  "B12",'QA60'],
		['Blue', 'Green', 'Red', 'NIR', 'SWIR1', 'SWIR2', 'QA_PIXEL']);
}


//--------------------4.所有常用的指数公式-------------------------
function calVI(img) {
  var ndvi = img.normalizedDifference(['NIR', 'Red']).rename('NDVI');
  
//Mcfeeters 1996
  var ndwi=img.normalizedDifference(["Green", "NIR"]).rename("NDWI");
  
var ndbi=img.normalizedDifference(["SWIR1", "NIR"]).rename("NDBI");

  var rvi = img.expression(  'NIR / RED ', 
  {  
      'NIR': img.select("NIR"),  
      'RED': img.select("Red")
  }).rename('RVI'); 
  
  
  var dvi = img.expression(  'NIR - RED ', 
  {  
      'NIR': img.select('NIR'),  
      'RED': img.select('Red')
  }).rename('DVI');  

            
  return img.addBands(ndvi).addBands(ndwi).addBands(ndbi).addBands(rvi).addBands(dvi);
}

var s2 = ee.ImageCollection('COPERNICUS/S2_SR')
                  .filterDate('2022-01-01', '2022-12-31')
                  .filterBounds(training)
                  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',5))
                  .map(maskS2clouds).map(renameS2_SR).map(calVI)//.select(["B1"]).median().clip(roi1); //


print(s2.first())
print(s2)
print(s2.size())
//ee.ImageCollection.fromImages([image1])

var image1=ee.Image("COPERNICUS/S2_SR/20220115T032101_20220115T032101_T49SEA").select(["B1"])
//print(image1)
var image2=ee.Image("COPERNICUS/S2_SR/20220405T031541_20220405T032316_T49SEA").select(["B1"])
var image3=ee.Image("COPERNICUS/S2_SR/20220410T031539_20220410T032318_T49SEA").select(["B1"])

// var listimage = ee.List([image1,image2,image3])
// print(listimage.get(0))

var imagess = image1.addBands(image2).addBands(image3)




  var values = imagess.reduceRegions({
		collection:training,
		reducer:ee.Reducer.mean(),
	scale:10,
//	crs:null,
//	crsTransform:null,
//	tileScale:true,
})
  print(i+"image values", values )





Export.table.toDrive({
		collection:values,
//	description:,
//	folder:,
//	fileNamePrefix:,
//	fileFormat:,
//	selectors:,
//	maxVertices:,
})


  
}

提取3景影像的B1波段的属性值 

GEE:获取sentinel2指定区域多个单景影像的值(样本点提取)_javascript_02

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  f18CFixvrKz8   2024年05月20日   87   0   0 JavaScript
  fxrR9b8fJ5Wh   2024年05月17日   50   0   0 JavaScript
  2xk0JyO908yA   2024年04月28日   37   0   0 JavaScript
u6lSrlpjxquL