1

I am very new to GEE and I'm even having difficulties deciphering other people's potential solutions.

After processing each data source into one imageCollection each, I am trying to make a simple calculation between these two. One of the ideas that I had is to combine both imageCollections into one image collection where each image have bands from imageCollection1 and imageCollection2. I tried the solution in the link, and while the join is successful, it doesn't seem to be able to add the second band. Is it because the metadata of the two imageCollections are different ?

https://code.earthengine.google.com/c0bb0bbdccf975d144b52031321795b6

var GRACE = ee.ImageCollection('NASA/GRACE/MASS_GRIDS/LAND')
                  .filter(ee.Filter.date('2003-08-01', '2003-12-01')).select('lwe_thickness_csr');

print(GRACE, 'GRACE')

var SWS = ee.ImageCollection('NASA/FLDAS/NOAH01/C/GL/M/V001');
SWS = SWS.filterDate('2003-08-01', '2003-12-01').select('SoilMoi100_200cm_tavg');


/// Get information about the GRACE projection.
var graceProjection = GRACE.first().projection();

///Resampling to meet GRACE resolution
var resampleSWS = SWS.map(function(image) {
    var mean = image
      // Force the next reprojection to aggregate instead of resampling.
     .reduceResolution({
        reducer: ee.Reducer.mean(),
       maxPixels: 1024
     }).rename('resampled SWS')
     // Request the data at the scale and projection of the GRACE image.
      .reproject({
       crs: graceProjection
     });
      return mean.set('system:time_start', image.get('system:time_start'))
})

print(resampleSWS, 'resampled SWS')


///Combine two image collections
var mod1 = GRACE.select('lwe_thickness_csr')
var mod2 = resampleSWS.select('resampled SWS')

var filter = ee.Filter.equals({
  leftField: 'system:time_start',
  rightField: 'system:time_start'
});

// Create the join.
var simpleJoin = ee.Join.simple();

// Applt join
var mod1join = ee.ImageCollection(simpleJoin.apply(mod1, mod2, filter))
var mod2join = ee.ImageCollection(simpleJoin.apply(mod2, mod1, filter))

print('Joined', mod1join, mod2join)

I don't see to be able to get this running right. Any suggestions?

3

I think the solution you're looking for is an inner join. It's described here

///Combine two image collections
var mod1 = GRACE.select('lwe_thickness_csr')
var mod2 = resampleSWS.select('resampled SWS')

var filter = ee.Filter.equals({
  leftField: 'system:time_start',
  rightField: 'system:time_start'
});

// Create the join.
var simpleJoin = ee.Join.inner();

// Inner join
var innerJoin = ee.ImageCollection(simpleJoin.apply(mod1, mod2, filter))

var joined = innerJoin.map(function(feature) {
  return ee.Image.cat(feature.get('primary'), feature.get('secondary'));
})

print('Joined', joined)
  • Indeed it worked perfectly. The fact that it matches between all the elements saved me so much time as it also joins the images with the same timestamp. Thank you so much! – Ahmed Walid Moulahoum Jul 5 at 13:00
  • If you can, modify the question and add the code to it. – Rodrigo E. Principe Jul 5 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.