feat(S1andS2_download): 完善Sentinel-2 L2A数据缺失情况下的平替处理逻辑.
This commit is contained in:
parent
a4c81d0813
commit
7347cd60bb
@ -2,15 +2,15 @@
|
|||||||
* Sentinel-1 & Sentinel-2 哨兵一号与二号长时序数据下载 —— 适用于小范围区域年度数据获取
|
* Sentinel-1 & Sentinel-2 哨兵一号与二号长时序数据下载 —— 适用于小范围区域年度数据获取
|
||||||
*
|
*
|
||||||
* @author CVEO Team
|
* @author CVEO Team
|
||||||
* @date 2026-01-06
|
* @date 2026-01-07
|
||||||
*
|
*
|
||||||
* 1. 加载 Sentinel-1, Sentinel-2 数据与 Cloud Score+ 云掩膜, 以及 HLS 数据
|
* 1. 加载 Sentinel-1 GRD, Sentinel-2 L2A SR数据与 Cloud Score+ 云掩膜, 以及 HLS 数据
|
||||||
* 2. 合成年度Sentinel-1, Sentinel-2, HLS无云影像
|
* 2. 合成年度Sentinel-1, Sentinel-2, HLS无云影像
|
||||||
* 3. 使用 HLS 影像作为 Sentinel-2 影像的补充
|
* 3. 使用 Sentinel-2 L1C TOA 影像与 HLS 影像作为 Sentinel-2 L2A SR 影像的补充
|
||||||
* 4. 合并 Sentinel-1 和 Sentinel-2 影像
|
* 4. 合并 Sentinel-1 和 Sentinel-2 影像
|
||||||
* 5. 导出 COG 云优化并填补缺失值的 GeoTIFF 影像 (小区域不分块)
|
* 5. 导出 COG 云优化并填补缺失值的 GeoTIFF 影像 (小区域不分块)
|
||||||
*
|
*
|
||||||
* 注: 截止至 2026-01-05, GEE 仍未集成 2015-2017 年的 L2A 数据, 且 2018 年的 L2A 数据仍不完整.
|
* 注: 截止至 2026-01-07, GEE 仍未集成 2015-2017 年的 Sentinel-2 L2A SR数据, 且 2018 年的 L2A 数据仍不完整.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 加载研究区域和影像
|
// 加载研究区域和影像
|
||||||
@ -20,7 +20,7 @@ var name_list = [
|
|||||||
"高雄左营区左营军港",
|
"高雄左营区左营军港",
|
||||||
"高雄旗山区陆军第八军团指挥部",
|
"高雄旗山区陆军第八军团指挥部",
|
||||||
];
|
];
|
||||||
var target_index = 0; // 从 0 开始计数, 0-3
|
var target_index = 1; // 从 0 开始计数, 0-3
|
||||||
var region_name = name_list[target_index];
|
var region_name = name_list[target_index];
|
||||||
var region = ee.FeatureCollection(
|
var region = ee.FeatureCollection(
|
||||||
demoPoints
|
demoPoints
|
||||||
@ -29,7 +29,7 @@ var region = ee.FeatureCollection(
|
|||||||
.buffer(3000)
|
.buffer(3000)
|
||||||
.bounds()
|
.bounds()
|
||||||
);
|
);
|
||||||
var start_year = 2018;
|
var start_year = 2015;
|
||||||
var end_year = 2025;
|
var end_year = 2025;
|
||||||
var start_date = start_year + "-" + "01-01";
|
var start_date = start_year + "-" + "01-01";
|
||||||
var end_date = start_year + "-" + "12-31";
|
var end_date = start_year + "-" + "12-31";
|
||||||
@ -38,6 +38,7 @@ var cloud_threshold = 100; // 最大云量阈值
|
|||||||
var QA_BAND = "cs_cdf";
|
var QA_BAND = "cs_cdf";
|
||||||
// The threshold for masking; values between 0.50 and 0.65 generally work well.
|
// The threshold for masking; values between 0.50 and 0.65 generally work well.
|
||||||
// Higher values will remove thin clouds, haze & cirrus shadows.
|
// Higher values will remove thin clouds, haze & cirrus shadows.
|
||||||
|
// 内陆建议设置为 0.8, 沿海或大江大湖旁建议设置为 0.6
|
||||||
var CLEAR_THRESHOLD = 0.8;
|
var CLEAR_THRESHOLD = 0.8;
|
||||||
var L30Bands = ["B2", "B3", "B4", "B5", "B6", "B7"];
|
var L30Bands = ["B2", "B3", "B4", "B5", "B6", "B7"];
|
||||||
// Sentinel-2的B8A波段(20m)可能更适合代表近红外波段
|
// Sentinel-2的B8A波段(20m)可能更适合代表近红外波段
|
||||||
@ -156,7 +157,7 @@ var S1VVdataset = S1dataset.filter(
|
|||||||
var S1VHdataset = S1dataset.filter(
|
var S1VHdataset = S1dataset.filter(
|
||||||
ee.Filter.listContains("transmitterReceiverPolarisation", "VH")
|
ee.Filter.listContains("transmitterReceiverPolarisation", "VH")
|
||||||
).select("VH");
|
).select("VH");
|
||||||
print(start_date + " - " + end_date + " S1dataset", S1dataset);
|
print(start_date + " - " + end_date + " Sentinel-1 dataset", S1dataset);
|
||||||
var s1_vv_img = ee.Image(S1VVdataset.median());
|
var s1_vv_img = ee.Image(S1VVdataset.median());
|
||||||
var s1_vh_img = ee.Image(S1VHdataset.median());
|
var s1_vh_img = ee.Image(S1VHdataset.median());
|
||||||
|
|
||||||
@ -167,22 +168,47 @@ var s1_vh_img = ee.Image(S1VHdataset.median());
|
|||||||
// Cloud Score+ image collection.
|
// Cloud Score+ image collection.
|
||||||
// Note Cloud Score+ is produced from Sentinel-2 level 1C data and can be applied to either L1C or L2A collections.
|
// Note Cloud Score+ is produced from Sentinel-2 level 1C data and can be applied to either L1C or L2A collections.
|
||||||
var S2csPlus = ee.ImageCollection("GOOGLE/CLOUD_SCORE_PLUS/V1/S2_HARMONIZED");
|
var S2csPlus = ee.ImageCollection("GOOGLE/CLOUD_SCORE_PLUS/V1/S2_HARMONIZED");
|
||||||
var S2dataset = ee
|
var S2TOAdataset = ee
|
||||||
|
.ImageCollection("COPERNICUS/S2_HARMONIZED")
|
||||||
|
.filter(common_filter)
|
||||||
|
.filter(ee.Filter.lt("CLOUDY_PIXEL_PERCENTAGE", cloud_threshold))
|
||||||
|
.linkCollection(S2csPlus, [QA_BAND])
|
||||||
|
.map(maskS2cloudsByCS)
|
||||||
|
.select(s2Bands, commonBands);
|
||||||
|
var targetS2TOACol = sortedByPriority(S2TOAdataset, region);
|
||||||
|
var s2_toa_img = ee.Image(targetS2TOACol.mosaic());
|
||||||
|
// 加载SIAC工具集, 容易爆内存
|
||||||
|
// var SIAC = require("users/marcyinfeng/utils:SIAC");
|
||||||
|
// var s2_boa_img = SIAC.get_sur(s2_toa_img.clip(region));
|
||||||
|
print(start_date + " - " + end_date + " Sentinel-2 TOA dataset", S2TOAdataset);
|
||||||
|
|
||||||
|
var S2SRdataset = ee
|
||||||
.ImageCollection("COPERNICUS/S2_SR_HARMONIZED")
|
.ImageCollection("COPERNICUS/S2_SR_HARMONIZED")
|
||||||
.filter(common_filter)
|
.filter(common_filter)
|
||||||
.filter(ee.Filter.lt("CLOUDY_PIXEL_PERCENTAGE", cloud_threshold))
|
.filter(ee.Filter.lt("CLOUDY_PIXEL_PERCENTAGE", cloud_threshold))
|
||||||
.linkCollection(S2csPlus, [QA_BAND])
|
.linkCollection(S2csPlus, [QA_BAND])
|
||||||
.map(maskS2cloudsByCS)
|
.map(maskS2cloudsByCS)
|
||||||
.select(s2Bands, commonBands);
|
.select(s2Bands, commonBands);
|
||||||
var targetS2Col = sortedByPriority(S2dataset, region);
|
var targetS2SRCol = sortedByPriority(S2SRdataset, region);
|
||||||
var s2_img = ee.Image(targetS2Col.mosaic());
|
var s2_sr_img = ee.Image(targetS2SRCol.mosaic());
|
||||||
print(start_date + " - " + end_date + " S2dataset", S2dataset);
|
print(start_date + " - " + end_date + " Sentinel-2 SR dataset", S2SRdataset);
|
||||||
|
|
||||||
// 2015-2018 年间若 Sentinel-2 数据为空, 则使用重采样到 10m 的 HLS 数据
|
var s2_img = ee.Image();
|
||||||
if (
|
// 2015-2018 年间若 Sentinel-2 SR 数据为空, 则使用 Sentinel-2 TOA 数据
|
||||||
S2dataset.size().getInfo() === 0 ||
|
// 若仍然没有, 则使用重采样到 10m 的 HLS 数据
|
||||||
(start_year === 2018 && (target_index === 0 || target_index === 3))
|
if (S2SRdataset.size().getInfo() === 0 && S2TOAdataset.size().getInfo() !== 0) {
|
||||||
) {
|
s2_img = s2_toa_img;
|
||||||
|
} else if (S2TOAdataset.size().getInfo() === 0 || start_year === 2015) {
|
||||||
|
s2_img = hls_10m_img;
|
||||||
|
} else {
|
||||||
|
s2_img = s2_sr_img;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 针对试点区域的特殊设置
|
||||||
|
if (start_year === 2018 && (target_index === 0 || target_index === 3)) {
|
||||||
|
s2_img = s2_toa_img;
|
||||||
|
}
|
||||||
|
if (start_year === 2016 && target_index === 1) {
|
||||||
s2_img = hls_10m_img;
|
s2_img = hls_10m_img;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +247,7 @@ var styling = {
|
|||||||
Map.centerObject(region, 14);
|
Map.centerObject(region, 14);
|
||||||
Map.addLayer(s1_vv_img, s1_vis, start_year + " Sentinel-1 GRD VV", false);
|
Map.addLayer(s1_vv_img, s1_vis, start_year + " Sentinel-1 GRD VV", false);
|
||||||
Map.addLayer(s1_vh_img, s1_vis, start_year + " Sentinel-1 GRD VH", false);
|
Map.addLayer(s1_vh_img, s1_vis, start_year + " Sentinel-1 GRD VH", false);
|
||||||
Map.addLayer(hls_img, true_rgb_vis, start_year + " HLS True RGB");
|
Map.addLayer(hls_img, true_rgb_vis, start_year + " HLS True RGB 30m");
|
||||||
Map.addLayer(hls_10m_img, true_rgb_vis, start_year + " HLS True RGB 10m");
|
Map.addLayer(hls_10m_img, true_rgb_vis, start_year + " HLS True RGB 10m");
|
||||||
Map.addLayer(
|
Map.addLayer(
|
||||||
s2_img_frgb,
|
s2_img_frgb,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user