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,除非它存在,等等)。
返回。图像
代码:
-
//显示如何叠加Sentinel-2和Sentinel-1带的脚本用于监督分类
-
var basin = ee.FeatureCollection("WWF/HydroSHEDS/v1/Basins/hybas_7")
-
var arkavathy = basin.filter(ee.Filter.eq('HYBAS_ID', 4071139640))
-
var boundary = arkavathy.geometry()
-
var s2 = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED')
-
//可视化参数
-
var rgbVis = {
-
min: 0.0,
-
max: 3000,
-
bands: ['B4', 'B3', 'B2'],
-
};
-
// 从Sentinel-2 SR图像中去除云和雪像素的功能
-
function maskCloudAndShadowsSR(image) {
-
var cloudProb = image.select('MSK_CLDPRB');
-
var snowProb = image.select('MSK_SNWPRB');
-
var cloud = cloudProb.lt(10);
-
var scl = image.select('SCL');
-
var shadow = scl.eq(3); // 3 = cloud shadow
-
var cirrus = scl.eq(10); // 10 = cirrus
-
// 云层概率小于10%或云影分类
-
var mask = cloud.and(cirrus.neq(1)).and(shadow.neq(1));
-
return image.updateMask(mask).divide(10000);
-
}
-
//影像的时间筛选和边界筛选以及去云后的波段选择
-
var filtered = s2
-
.filter(ee.Filter.date('2019-01-01', '2020-01-01'))
-
.filter(ee.Filter.bounds(boundary))
-
.map(maskCloudAndShadowsSR)
-
.select('B.*')
-
//裁剪影像
-
var composite = filtered.median().clip(boundary)
-
//加载S1影像
-
var s1 = ee.ImageCollection("COPERNICUS/S1_GRD")
-
//对sentinel1进行筛选
-
var filtered = s1
-
// 滤镜以获得具有VV和VH双偏振的图像。
-
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))//发送器接收器极化
-
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
-
.filter(ee.Filter.eq('instrumentMode', 'IW'))
-
// 根据你的位置,将通行证改为ASCENDING
-
.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))
-
.filterDate('2019-01-01', '2020-01-01')
-
.filterBounds(boundary)
-
.select('V.')
-
// 平均值合成sar数据
-
var sarComposite = filtered.mean()
-
//让S2影像加载S1的波段
-
var composite = composite.addBands(sarComposite)
-
print(composite);
-
//这样我们就可以将上面的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. |
影像合成后的结果: