如何在Google Earth Engine中结合图像?
因此,从Sentinel 5p图像集合中,我创建了3个不同的图像3年(平均-2019、2020和2021)。然后,我使用几何形状剪切了这3张图像,然后再次制作了3张图像。现在,我想将这3张图像组合到一个图像中,以便在从该组合图像中提取数据时,我将能够在3年(2019年,2020年和2021年)中获取数据。 我尝试了此方法 -
var simpleJoin = ee.Join.simple();
var mod1join = ee.ImageCollection(simpleJoin.apply(img1clip, img2clip, img3clip));
Map.addLayer(mod1join, band_viz);
但是在加载图层时,它给了我一个错误 -
第1层:层错误:join.apply,参数'secondary':无效类型。预期类型:特征汇编。实际类型:图像< [SO2_COLUMN_NUMBER_DESSION]>。
我尝试搜索此错误,但找不到任何解决方案。 结合不同年份的3张图像,保留这些特定年份的数据的解决方案是什么?
在下面,我正在附加我所做的和尝试的代码-FYI
var img1 = ee.ImageCollection(imageCollection
.select('SO2_column_number_density')
.filterBounds(geometry)
.filterDate('2019-01-01', '2019-12-31'))
//remove the negative values from the band
//.map(function(image){return image.updateMask(image.gte(0))});
print('no. of img1', img1.size());
var img2 = ee.ImageCollection(imageCollection
.select('SO2_column_number_density')
.filterBounds(geometry)
.filterDate('2020-01-01', '2020-12-31'))
print('no. of img2', img2.size());
var img3 = ee.ImageCollection(imageCollection
.select('SO2_column_number_density')
.filterBounds(geometry)
.filterDate('2021-01-01', '2021-12-31'))
print('no. of img3', img3.size());
var band_viz = {
min: 0.0,
max: 0.0005,
palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};
var img1map = img1.mean();
var img2map = img2.mean();
var img3map = img3.mean();
//Map.addLayer (SP5map, band_viz);
var img1clip = img1map.clip(geometry);
var img2clip = img2map.clip(geometry);
var img3clip = img3map.clip(geometry);
//print(img1clip);
var simpleJoin = ee.Join.simple();
var mod1join = ee.ImageCollection(simpleJoin.apply(img1clip, img2clip, img3clip));
Map.addLayer(mod1join, band_viz);
:所有3个剪裁的图像仅包含1个频段。
So from the Sentinel 5P image collection I created 3 different images for 3 years (mean of - 2019, 2020 and 2021). Then I clipped those 3 images using a Geometry and then again 3 images were made. Now I want to combine these 3 images into a single one so that while extracting data from that combined image I will be able to get data for the 3 years (2019, 2020 and 2021).
I tried this method -
var simpleJoin = ee.Join.simple();
var mod1join = ee.ImageCollection(simpleJoin.apply(img1clip, img2clip, img3clip));
Map.addLayer(mod1join, band_viz);
But while loading the layer it gives me an error -
Layer 1: Layer error: Join.apply, argument 'secondary': Invalid type. Expected type: FeatureCollection. Actual type: Image<[SO2_column_number_density]>.
I tried searching for this error but did not find any solution.
What will be the solution to combine the 3 images of different years, keeping the data for those particular years as well?
Below I am attaching the code of what I did and tried -
var img1 = ee.ImageCollection(imageCollection
.select('SO2_column_number_density')
.filterBounds(geometry)
.filterDate('2019-01-01', '2019-12-31'))
//remove the negative values from the band
//.map(function(image){return image.updateMask(image.gte(0))});
print('no. of img1', img1.size());
var img2 = ee.ImageCollection(imageCollection
.select('SO2_column_number_density')
.filterBounds(geometry)
.filterDate('2020-01-01', '2020-12-31'))
print('no. of img2', img2.size());
var img3 = ee.ImageCollection(imageCollection
.select('SO2_column_number_density')
.filterBounds(geometry)
.filterDate('2021-01-01', '2021-12-31'))
print('no. of img3', img3.size());
var band_viz = {
min: 0.0,
max: 0.0005,
palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};
var img1map = img1.mean();
var img2map = img2.mean();
var img3map = img3.mean();
//Map.addLayer (SP5map, band_viz);
var img1clip = img1map.clip(geometry);
var img2clip = img2map.clip(geometry);
var img3clip = img3map.clip(geometry);
//print(img1clip);
var simpleJoin = ee.Join.simple();
var mod1join = ee.ImageCollection(simpleJoin.apply(img1clip, img2clip, img3clip));
Map.addLayer(mod1join, band_viz);
FYI: All the 3 clipped images contain only 1 band.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从官方文档,第一个&amp;
ee.join.apply()
的第二个参数都是farmaturecollection
,而第三个参数为filter
。一个工作示例是在这里。img1
是collection
在应用后.filterdate()
img1clip
是image> image
之后您应用.mean()
函数img1clip
也是image> image
后,您应用.clip(.clip()
,不是farmaturecollection
。因此,出现错误(无效类型)。
您必须查看代码并确保
ee.join.apply()
的三个参数是正确的。From the official documentation, the first & second parameter of
ee.Join.apply()
are bothFeatureCollection
, while the third parameter is aFilter
. A working example is here.img1
is anCollection
after applied.filterDate()
img1clip
is anImage
after you applied.mean()
functionimg1clip
is also anImage
after you applied.clip()
, which is NOT aFeatureCollection
.Therefore the error appears (Invalid Type).
You have to review the codes and ensure the three parameters of
ee.Join.apply()
are correct.如果您正在使用图像,则将它们添加为“频段”:
使用“ Inspector”,您将看到三个频段的信息。
If you are working with images, add them as "bands":
With "inspector" you will see the information from the three bands.