0

I want to download the biweekly means of certain periods May-Sep of ERA5 data within a certain roi. (Mainly just Air/Soil Temp and Precip. The code I provided I just filtered for 2 weeks then applied .mean() in the visualization just to see how it looks. My first question is: if I just apply .mean() will it take a mean of all the days in the date I provided. My second question: should I use the hourly and take the mean? Or would the daily aggregate work just as well? Any advice would be helpful.

var roi = ee.FeatureCollection("projects/daniel-schartonproject/assets/roi")

var dataset = ee.ImageCollection('ECMWF/ERA5_LAND/DAILY_AGGR').filterDate("2025-08-04","2025-08-04");

var visualization = {
  bands: ['temperature_2m'],
  min: 250,
  max: 320,
  palette: [
    '000080', '0000d9', '4000ff', '8000ff', '0080ff', '00ffff',
    '00ff80', '80ff00', 'daff00', 'ffff00', 'fff500', 'ffda00',
    'ffb000', 'ffa400', 'ff4f00', 'ff2500', 'ff0a00', 'ff00ff',
  ]
};
Map.setCenter(70, 45, 3);
Map.addLayer(
    dataset.mean(), visualization, 'Air temperature (K) at 2m height', true, 0.8);
3
  • I think that Google Earth Engine (GEE) typically provides data at specific intervals such as hourly, daily, monthly, and yearly. For ERA5 data, bi-weekly data is not directly available for download. However, you can process daily ERA5 data to generate bi-weekly averages or sums, depending on your requirements. You could also rephrase your question. The mean would estimate the values taking into account the entire time period. Commented Jul 1, 2024 at 14:56
  • @IliasMachairas I updated my question, hopefully that is better Commented Jul 1, 2024 at 15:31
  • From my understanding, 1. mean() produces a 'mean image' - this function takes the mean for each pixel in the time range you've provided to filter the image collection and squishes the entire collection into one single image - by applying a mean reducer one this image you could produce a single 'mean value' for the time range and boundary you've provided 2. Daily aggregate would suffice
    – aeaturu
    Commented Jul 1, 2024 at 16:06

1 Answer 1

0

Since mean calculates the mean of all the observations in the collections (as mentioned in the comments sections), you need to create a loop to calculate the mean value in biweekly windows. Thus, you need to create a list containing the number of biweekly windows from your startDate to endDate and calculate the mean for each one. Here is the code that does precisely that.

// Set start and end Dates
var startDate = "2025-08-04"
var endDate = "2025-08-04"

var dataset = ee.ImageCollection('ECMWF/ERA5_LAND/DAILY_AGGR')
                .filterDate(startDate,endDate);

// Get difference in weeks from start to end dates
var difWeeks = ee.Date.parse("Y-M-d",endDate).difference(
ee.Date.parse("Y-M-d",startDate), "week").round();

// Create sequence of weeks in steps of 2 weeks
var weeks = ee.List.sequence(0, difWeeks, 2);

// Create loop base on the list of weeks
var biweekMean = weeks.map(function(week){
  // Create start date based on the startDate and advance 
  // the number of weeks in the current cycle
  var start = ee.Date.parse("Y-M-d", startDate)
                     .advance(week, "week");
  // Advance 2 weeks from start date                   
  var end = start.advance(2, "week");
  
  // Filter Image Collection based on start and end
  // Calculate mean value and set a time property
  var resul = dataset.filterDate(start, end)
                     .mean()
                     .set('system:time_start',
                          start);
  return resul;
});

// Collection with biweekly composites
biweekMean = ee.ImageCollection.fromImages(biweekMean);

print('biweekMean', biweekMean);

// Visualize
var visualization = {
  bands: ['temperature_2m'],
  min: 250,
  max: 320,
  palette: [
    '000080', '0000d9', '4000ff', '8000ff', '0080ff', '00ffff',
    '00ff80', '80ff00', 'daff00', 'ffff00', 'fff500', 'ffda00',
    'ffb000', 'ffa400', 'ff4f00', 'ff2500', 'ff0a00', 'ff00ff',
  ]
};
Map.setCenter(70, 45, 3);
Map.addLayer(biweekMean.first(), visualization, 'Air temperature (K) at 2m height', true, 0.8);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.