I'm trying to get the average value within a week timeframe, for every band, for every dataset of Sentinel 5P on Google Earth Engine, for a 10km radius around a point.
The part I'm having trouble with is efficiently joining (currently with an inner join?) the various Sentinel 5P datasets together.
This is currently resulting in an empty dictionary as the result of .getInfo()
, where as if I use reduceRegion
on a single image (i.e. the mean of a single dataset filtered by date) I get a reasonable response. I've done this before by looping through the databases, but I'm assuming there is a much more efficient way.
How can I efficiently apply a reduceRegion
across multiple earth engine datasets at the same time?
start_date = '01-01-2019'
next_date = '01-08-2019'
geometry = ee.Geometry.Point(lon=lon, lat=lat).buffer(1e5) #10 km around an arbitrary point
EARTHENGINE_DBS = [
"COPERNICUS/S5P/OFFL/L3_NO2",
"COPERNICUS/S5P/OFFL/L3_SO2",
"COPERNICUS/S5P/OFFL/L3_CO",
"COPERNICUS/S5P/OFFL/L3_HCHO",
"COPERNICUS/S5P/OFFL/L3_O3",
]
# -- Make a date filter to get images in this date range. --
dateFilter = ee.Filter.date(start_date, next_date)
# --- Select imaged collection ---
ic = ee.ImageCollection(EARTHENGINE_DBS[0])
for db in EARTHENGINE_DBS[1:]:
# --- Define the new data ---
_new = ee.ImageCollection(db).filter(dateFilter)
# --- Define an inner join. ---
innerJoin = ee.Join.inner()
# --- Specify an equals filter for image timestamps. ---
filterTimeEq = ee.Filter.equals(** {
'leftField': 'system:time_start',
'rightField': 'system:time_start'
})
# --- Apply the join. ---
ic = innerJoin.apply(ic, _new, filterTimeEq)
# --- flatten ---
ic = ic.map(lambda feature: ee.Image.cat(feature.get('primary'), feature.get('secondary')))
# --- aggregate ic ---
agg_ic = ic.mean()
mean_dict = agg_ic.reduceRegion(**{
'reducer': ee.Reducer.mean(),
'geometry':geometry,
'scale': 1000,
'bestEffort':True,
'tileScale':16
})
mean_dict.getInfo()
.select()
to lower the number of bands requested.