2

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.

Raptor
  • 53,206
  • 45
  • 230
  • 366

2 Answers2

0

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.

Raptor
  • 53,206
  • 45
  • 230
  • 366
0

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.

Sabuncu
  • 5,095
  • 5
  • 55
  • 89
Maria
  • 1