I am trying to compare images aquired from two different sensors: MSI on board of Sentinel-2 and MODIS on board of Terra, using Google Earth Engine. MODIS provides his own band of the parameter I am instered in at 500 km resolution concentrantion meanwhile I created my own algorithm in Sentinel-2 at finer resolution. I want to compare the results over a specific area but first I want to filter the two collections by selecting only images that were aquired approximately on the same date, it only matters the YYYY-MM-DD. Specifically TERRA has a daily temporal resolution over the selected area while Sentinel-2 5 days. Basically I want to reduce the MODIS collection selecting only those images overlapping temporally with Sentinel-2. Note that I will nead to map the results. I don't have any idea on how to do it, I came across the function 'inner.Join' but I don't know how to use it. I am not planning to merge them into one Image collection, I want to keep them separetely
1 Answer
I actually tried this and somehow seems it works, could be a solution. If someone want to check it and see if it works here it is: First I defined the date by doing .map over both collections with the following code:
.map(function(image) {
var date = ee.Date(image.get('system:time_start')).format("YYYY-MM-dd");
date = ee.Date(date);
return image.set('date', date);
})
;
The code above adds an extra property 'date' in the format YYYY-MM-dd to the collections. I did it because it seems that if I only use 'system:time_start' it doesen't find any matching dates, perhaps due to different time of aquisition?
var filterTimeEq = ee.Filter.equals({
leftField: 'date',
rightField: 'date'
});
var simpleJoin = ee.Join.simple()
var simpleJoinedCollection = simpleJoin.apply(first_coll, second_coll, filterTimeEq)
var collection= ee.ImageCollection(simpleJoinedCollection)
Map.addLayer(collection)