如何在Google Earth Engine中结合图像?

发布于 2025-02-10 19:45:43 字数 1828 浏览 1 评论 0原文

因此,从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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟酉 2025-02-17 19:45:43

官方文档,第一个&amp; ee.join.apply()的第二个参数都是farmaturecollection,而第三个参数为filter。一个工作示例是在这里

  1. img1collection在应用后.filterdate()
  2. img1clipimage> image之后您应用.mean()函数
  3. img1clip也是image> image后,您应用.clip(.clip(),不是farmaturecollection

因此,出现错误(无效类型)。

您必须查看代码并确保ee.join.apply()的三个参数是正确的。

From the official documentation, the first & second parameter of ee.Join.apply() are both FeatureCollection, while the third parameter is a Filter. A working example is here.

  1. img1 is an Collection after applied .filterDate()
  2. img1clip is an Image after you applied .mean() function
  3. the img1clip is also an Image after you applied .clip(), which is NOT a FeatureCollection.

Therefore the error appears (Invalid Type).

You have to review the codes and ensure the three parameters of ee.Join.apply() are correct.

谈情不如逗狗 2025-02-17 19:45:43

如果您正在使用图像,则将它们添加为“频段”:

var mod1join = img1clip.addBands(img1clip).addBands(img1clip);
Map.addLayer(mod1join, band_viz);

使用“ Inspector”,您将看到三个频段的信息。

If you are working with images, add them as "bands":

var mod1join = img1clip.addBands(img1clip).addBands(img1clip);
Map.addLayer(mod1join, band_viz);

With "inspector" you will see the information from the three bands.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文