This question is based on a previous post: Filter two image collections by the same aqusition date in Google Earth Engine
I would like to expand the question to try to filter collections to get images that are within one day of each other (i.e., image from collection 1 is within +/- one day of image from collection 2).
I have written the following code in geemap (based on previous question) to get coincident image dates, given two image collections:
col1 = ee.ImageCollection('LANDSAT/LE07/C02/T1_L2') \ .filter(ee.Filter.calendarRange(1998, 2013,'year')) \ .filterBounds(pts) col2 = ee.ImageCollection('LANDSAT/LT05/C02/T1_L2') \ .filter(ee.Filter.calendarRange(1998, 2012,'year')) \ .filterBounds(pts) def datefunc(image): date = ee.Date(image.get('system:time_start')).format("YYYY-MM-dd") date = ee.Date(date) return image.set('date', date) col1_date = col1.map(datefunc) col2_date = col2.map(datefunc) filterTimeEq = ee.Filter.equals( leftField='date', rightField='date' ) simpleJoin = ee.Join.simple() col_new = ee.ImageCollection(simpleJoin.apply(col1_date, col2_date, filterTimeEq))
Is there any way I can modify the above code to get near coincident imagery?