1

I'm new to GEE, and I've been trying to extract daily values from 3 climate parameters (minimum_2m_air_temperature, maximum_2m_air_temperature, and total_precipitation) from the ERA5 Daily Aggregates dataset. I tried using the code provided in this question with the minimum temperature, but the temperature value was null. Is there any way to fix this?

Please see the code I used:

Map.centerObject(ILPLS_shape);

var min_temp = ee.ImageCollection('ECMWF/ERA5/DAILY')
                   .select('minimum_2m_air_temperature')
                   .filter(ee.Filter.date('2016-12-01', '2018-03-02'));

var min_temp_list = min_temp.toList(min_temp.size());

print(min_temp_list);

var study_area = min_temp_list.map(function(img){
  
  var date = ee.Date(ee.Image(img).get('system:time_start')).format().slice(0, 10);
  img = ee.Image(img).subtract(273.15);
  
  // Getting the image value
  var value_temp = ee.Image(img)
    .get('minimum_2m_air_temperature');
  
  return [date, value_temp];
  
});

var vis2mt = {
  min: -20,
  max: -10,
  palette: [
    '#000080', '#0000D9', '#4000FF', '#8000FF', '#0080FF', '#00FFFF', '#00FF80',
    '#80FF00', '#DAFF00', '#FFFF00', '#FFF500', '#FFDA00', '#FFB000', '#FFA400',
    '#FF4F00', '#FF2500', '#FF0A00', '#FF00FF'
  ]
};

var image = ee.Image(min_temp_list.get(0))
  .subtract(273.15)
  .clip(ILPLS_shape);
print(image);

Map.addLayer(image, vis2mt);

print(study_area);

var myFeatures = ee.FeatureCollection(study_area.map(function(el){
  el = ee.List(el); // cast every element of the list

  return ee.Feature(null, {
    'date': el.get(0),
    'value_temp': el.get(1),
  });
}));

print(myFeatures);

1 Answer 1

0

You don't provide ILPLS_shape so, I arbitrarily created one. The issue is produced because you forgot to write 'reduceRegion' method in your code; as it can be observed as follows:

  // Getting the image value
  var value_temp = ee.Image(img)
    .get('minimum_2m_air_temperature');

It is mandatory to have:

  var value_temp = ee.Image(img)
    .reduceRegion(ee.Reducer.mean(), ILPLS_shape)
    .get('minimum_2m_air_temperature');

Fixing this, complete code is:

Map.centerObject(ILPLS_shape);

var min_temp = ee.ImageCollection('ECMWF/ERA5/DAILY')
                   .select('minimum_2m_air_temperature')
                   .filter(ee.Filter.date('2016-12-01', '2018-03-02'));

var min_temp_list = min_temp.toList(min_temp.size());

print(min_temp_list);

var study_area = min_temp_list.map(function(img){
  
  var date = ee.Date(ee.Image(img).get('system:time_start')).format().slice(0, 10);
  img = ee.Image(img).subtract(273.15);
  
  var value_temp = ee.Image(img)
    .reduceRegion(ee.Reducer.mean(), ILPLS_shape)
    .get('minimum_2m_air_temperature');
  
  return [date, value_temp];
  
});

var vis2mt = {
  min: -20,
  max: -10,
  palette: [
    '#000080', '#0000D9', '#4000FF', '#8000FF', '#0080FF', '#00FFFF', '#00FF80',
    '#80FF00', '#DAFF00', '#FFFF00', '#FFF500', '#FFDA00', '#FFB000', '#FFA400',
    '#FF4F00', '#FF2500', '#FF0A00', '#FF00FF'
  ]
};

var image = ee.Image(min_temp_list.get(0))
  .subtract(273.15)
  .clip(ILPLS_shape);
print(image);

Map.addLayer(image, vis2mt);

print(study_area);

var myFeatures = ee.FeatureCollection(study_area.map(function(el){
  el = ee.List(el); // cast every element of the list

  return ee.Feature(null, {
    'date': el.get(0),
    'value_temp': el.get(1),
  });
}));

print(myFeatures);

and after run it, you can observe at following picture that features have the second property named 'value_temp' without any null value.

enter image description here

Editing Note:

You're right. Your area only covers a pixel. So, the geometry needs to take its centroid. Following code, for your area in "Cagayan de Oro" (circled in blue in below picture), fix it.

https://code.earthengine.google.com/92ed2c63228deeb2b026c748ec53f59d

After running it at GEE code editor, at the following picture it can be observed the corresponding temperature values.

enter image description here

3
  • Thanks for the response, @xunilk I tried the code, but the value_temp still appears null. Maybe it has something to do with the size of my study area (ILPLS_shape)? Not sure how to share the geometry shapefile, but it is a 50-hectare protected area in my country. Looking at the ERA5 resolution, my area probably only covers a pixel. Would I still need a reduceRegion for this, or should I do something else?
    – mereinne
    Aug 31, 2023 at 4:35
  • Please see this photo for the size reference: imgur.com/a/eaFEfXp
    – mereinne
    Aug 31, 2023 at 4:50
  • Please, see my Editing Note.
    – xunilk
    Aug 31, 2023 at 20:10

Your Answer

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

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