土地利用数据|气象数据|社会经济数据|npp数据|ndvi数据-地理遥感生态网

Google Earth Engine (GEE)——如何用Sentinel-1和Sentinel-2影像融合为多波段影像做分类

Google Earth Engine (GEE)——如何用Sentinel-1和Sentinel-2影像融合为多波段影像做分类
Google Earth Engine (GEE)——如何用Sentinel-1和Sentinel-2影像融合为多波段影像做分类

详细信息

本教程的理念就是通过分别加载S2和S1影像,并且根据要求筛选出我们所需要的影像时间、位置以及波段及属性,我们就可以完成对整个影像的的添加,而这个影像的添加一般是通过波段的形式让其中一个影像集合添加到另外一个影像集合之上。从而用我们所选中的波段进行监督分类。

本文用到的函数:

ee.Filter.listContains(leftField, rightValue, rightField, leftValue)
创建一个一元或二元过滤器,如果左边的操作数(一个列表)包含右边的操作数,则通过。

参数。
leftField(字符串,默认:null)。
左边操作数的选择器。如果指定了leftValue,就不应该指定。

rightValue(对象,默认:null)。
右边操作数的值。如果指定了rightField,则不应该指定。

rightField(字符串,默认:null)。
右边操作数的选择器。如果指定了rightValue,则不应该指定。

leftValue(对象,默认:null)。
左边操作数的值。如果指定了leftField,则不应该指定。

返回。过滤器

addBands(srcImg, names, overwrite)
返回一张包含从第一张输入图片中复制的所有条带和从第二张输入图片中选择的条带的图片,可以选择覆盖第一张图片中相同名称的条带。新的图像具有第一个输入图像的元数据和足迹。

参数。
this:dstImg(图像)。
要复制带子的图像。

srcImg (图像)。
含有要复制带子的图像。

names(列表,默认为空)。
可选的要复制的频段名称列表。如果省略名称,srcImg中的所有条带都将被复制过来。

overwrite(布尔值,默认:false)。
如果为真,srcImg中的带子将覆盖dstImg中相同名称的带子。否则,新的频段将以数字后缀重新命名(foo到foo_1,除非foo_1存在,然后foo_2,除非它存在,等等)。

返回。图像

 

代码:


 
  1. //显示如何叠加Sentinel-2和Sentinel-1带的脚本用于监督分类

  2.  
  3. var basin = ee.FeatureCollection("WWF/HydroSHEDS/v1/Basins/hybas_7")

  4. var arkavathy = basin.filter(ee.Filter.eq('HYBAS_ID', 4071139640))

  5. var boundary = arkavathy.geometry()

  6. var s2 = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED')

  7.  
  8. //可视化参数

  9. var rgbVis = {

  10. min: 0.0,

  11. max: 3000,

  12. bands: ['B4', 'B3', 'B2'],

  13. };

  14.  
  15.  
  16. // 从Sentinel-2 SR图像中去除云和雪像素的功能

  17. function maskCloudAndShadowsSR(image) {

  18. var cloudProb = image.select('MSK_CLDPRB');

  19. var snowProb = image.select('MSK_SNWPRB');

  20. var cloud = cloudProb.lt(10);

  21. var scl = image.select('SCL');

  22. var shadow = scl.eq(3); // 3 = cloud shadow

  23. var cirrus = scl.eq(10); // 10 = cirrus

  24. // 云层概率小于10%或云影分类

  25. var mask = cloud.and(cirrus.neq(1)).and(shadow.neq(1));

  26. return image.updateMask(mask).divide(10000);

  27. }

  28.  
  29. //影像的时间筛选和边界筛选以及去云后的波段选择

  30. var filtered = s2

  31. .filter(ee.Filter.date('2019-01-01', '2020-01-01'))

  32. .filter(ee.Filter.bounds(boundary))

  33. .map(maskCloudAndShadowsSR)

  34. .select('B.*')

  35.  
  36. //裁剪影像

  37. var composite = filtered.median().clip(boundary)

  38.  
  39. //加载S1影像

  40. var s1 = ee.ImageCollection("COPERNICUS/S1_GRD")

  41. //对sentinel1进行筛选

  42. var filtered = s1

  43. // 滤镜以获得具有VV和VH双偏振的图像。

  44. .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))//发送器接收器极化

  45. .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))

  46. .filter(ee.Filter.eq('instrumentMode', 'IW'))

  47. // 根据你的位置,将通行证改为ASCENDING

  48. .filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))

  49. .filterDate('2019-01-01', '2020-01-01')

  50. .filterBounds(boundary)

  51. .select('V.')

  52.  
  53. // 平均值合成sar数据

  54. var sarComposite = filtered.mean()

  55. //让S2影像加载S1的波段

  56. var composite = composite.addBands(sarComposite)

  57.  
  58. print(composite);

  59.  
  60. //这样我们就可以将上面的S1和S2影像合成为一个影像集合去进行分别分类

这里有一点大家需要知道,我们使用filter一般筛选的是影像的属性信息,所以我们这里看到,在进行sentinel-1筛选的时候我们需要进行相应的属性筛选,我们这里先列出s1中包含的属性信息,大家可以通过属性去筛选所需要的信息。

Image Properties

Name Type Description
GRD_Post_Processing_facility_country STRING

Name of the country where the facility is located. This element is configurable within the IPF.

GRD_Post_Processing_facility_name STRING

Name of the facility where the processing step was performed. This element is configurable within the IPF.

GRD_Post_Processing_facility_organisation STRING

Name of the organisation responsible for the facility. This element is configurable within the IPF.

GRD_Post_Processing_facility_site STRING

Geographical location of the facility. This element is configurable within the IPF.

GRD_Post_Processing_software_name STRING

Name of the software.

GRD_Post_Processing_software_version STRING

Software version identification.

GRD_Post_Processing_start DOUBLE

Processing start time.

GRD_Post_Processing_stop DOUBLE

Processing stop time.

SLC_Processing_facility_country STRING

Name of the country where the facility is located. This element is configurable within the IPF.

SLC_Processing_facility_name STRING

Name of the facility where the processing step was performed. This element is configurable within the IPF.

SLC_Processing_facility_organisation STRING

Name of the organisation responsible for the facility. This element is configurable within the IPF.

SLC_Processing_facility_site STRING

Geographical location of the facility. This element is configurable within the IPF.

SLC_Processing_software_name STRING

Name of the software.

SLC_Processing_software_version STRING

Software version identification.

SLC_Processing_start DOUBLE

Processing start time.

SLC_Processing_stop DOUBLE

Processing stop time.

S1TBX_Calibration_Operator_version STRING

Sentinel-1 Toolbox calibration tool version.

S1TBX_SAR_Processing_version STRING

Sentinel-1 Toolbox SAR processing tool version.

SNAP_Graph_Processing_Framework_GPF_version STRING

Sentinel Application Platform (SNAP) version.

startTimeANX DOUBLE

Sensing start time of the input data relative to the ascending node crossing. This is a count of the time elapsed since the orbit ascending node crossing [ms].

stopTimeANX DOUBLE

Sensing stop time of the input data relative to the ascending node crossing. This is a count of the time elapsed since the orbit ascending node crossing [ms].

nssdcIdentifier STRING

Uniquely identifies the mission according to standards defined by the World Data Center for Satellite Information (WDC-SI), available here.

familyName STRING

The full mission name. E.g. "SENTINEL-1"

platform_number STRING

The alphanumeric identifier of the platform within the mission.

instrument STRING

Information related to the instrument on the platform to which acquired the data.

instrumentMode STRING

IW (Interferometric Wide Swath), EW (Extra Wide Swath) or SM (Strip Map)

instrumentSwath STRING

List of the swaths contained within a product. Most products will contain only one swath, except for TOPS SLC products which include 3 or 5 swaths.

orbitNumber_start DOUBLE

Absolute orbit number of the oldest line within the image data.

orbitNumber_stop DOUBLE

Absolute orbit number of the most recent line within the image data.

relativeOrbitNumber_start DOUBLE

Relative orbit number of the oldest line within the image data.

relativeOrbitNumber_stop DOUBLE

Relative orbit number of the most recent line within the image data.

cycleNumber DOUBLE

Absolute sequence number of the mission cycle to which the oldest image data applies.

phaseIdentifier DOUBLE

Id of the mission phase to which the oldest image data applies.

orbitProperties_pass STRING

Direction of the orbit ('ASCENDING' or 'DESCENDING') for the oldest image data in the product (the start of the product).

orbitProperties_ascendingNodeTime DOUBLE

UTC time of the ascending node of the orbit. This element is present for all products except ASAR L2 OCN products which are generated from an ASAR L1 input.

resolution STRING

H for high or M for medium.

resolution_meters DOUBLE

Resolution in meters.

instrumentConfigurationID DOUBLE

The instrument configuration ID (Radar database ID) for this data.

missionDataTakeID DOUBLE

Unique ID of the datatake within the mission.

transmitterReceiverPolarisation DOUBLE

Transmit/Receive polarisation for the data. There is one element for each Tx/Rx combination: [''VV''], [''HH''], [''VV'', ''VH''], or [''HH'', ''HV''].

productClass STRING

Output product class "A" for Annotation or "S" for Standard.

productClassDescription STRING

Textual description of the output product class.

productComposition STRING

The composition type of this product: "Individual", "Slice", or "Assembled".

productType STRING

The product type (correction level) of this product.

productTimelinessCategory STRING

Describes the required timeliness of the processing. One of: NRT-10m, NRT-1h, NRT-3h, Fast-24h, Off-line, or Reprocessing

sliceProductFlag STRING

True if this is a slice from a larger product or false if this is a complete product.

segmentStartTime DOUBLE

Sensing start time of the segment to which this slice belongs. This field is only present if sliceProductFlag = true

sliceNumber DOUBLE

Absolute slice number of this slice starting at 1. This field is only present if sliceProductFlag = true.

totalSlices DOUBLE

Total number of slices in the complete data take. This field is only present if sliceProductFlag = true.

 

影像合成后的结果: