本次我们在对影像进行合并的过程中的时候,难免会有一些差异,当然我们使用的一个函数是
union(maxError) 将给定集合中的所有几何体合并成一个集合,并返回一个只包含一个ID为'union_result'的单一特征和一个几何体的集合。
参数。 this:collection(特征集合)。 被合并的集合。
maxError(ErrorMargin,默认:null)。 在执行任何必要的重投影时允许的最大误差。如果没有指定,则默认为从输出中请求的误差幅度。
返回。特征集合
这里我们的所需要设定的参数是:maxError,当我们在使用的过程中发现因为年份的时间筛选,再2021年可以使用的,但再2022年必须得设定最大容许误差才可以使用,这是一个小的bug,本来以为是没有影像的缘故,但是影像再8月份已经全部再GEE上可以查询了,但是还会出现错误:
Geometry (Error)
Collection.geometry: Unable to perform this geometry operation. Please specify a non-zero error margin.
我们使用的研究区:
代码:
var geometry =
/* color: #98ff00 */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[32.317220082425564, 50.41769581039291],
[32.317220082425564, 49.797655363079855],
[33.547688832425564, 49.797655363079855],
[33.547688832425564, 50.41769581039291]]], null, false);
var collectionName = "COPERNICUS/S2_SR_HARMONIZED"
var s2 = ee.ImageCollection(collectionName).filterBounds(geometry)
// 同样在2021年的使用不用设定参数就可以使用
var bounds = s2.filterDate('2021-08-01', '2021-08-30').union().geometry()
print(bounds)
// 这里使用union却无法正常加载
var bounds = s2.filterDate('2022-08-01', '2022-08-30')//.union().geometry()
print(bounds)
// 但在工会中的工作是有误差的
var bounds = s2.filterDate('2022-08-01', '2022-08-30').union(0.1).geometry()
print(bounds)