2

I'm looking to make a climate zone map in Google Earth Engine (GEE). One of the criteria I'm using is frost occurrence- which is defined by having at least 7 days per year with a minimum temperature below 0 degrees Celsius. I'm doing this ideally over a 30-year period as well.

I'm using ERA5's daily minimum air temperature dataset to calculate this. I have created an image collection that has grouped all images of the same year together but am stuck on the next step.

How would I go about filtering down areas that have at least 7 days of minimum temps below zero per year (and vice versa- a variable containing global areas that do not have frost conditions) into variables from this grouped image collection?

// Daily mean 2m air temperature
var era_min_t = ee.ImageCollection("ECMWF/ERA5/DAILY")
  .filterDate('1990-01-01', '2020-01-01')
  .select('minimum_2m_air_temperature');

// Reduce the collection to a set of unique year representatives
// to serve as the primary collection in a join with the complete
// collection.
var distinctYear = era_min_t.distinct('year');
print(distinctYear, "Distinct Year");
// Define a filter that identifies which images from the complete collection
// match the 'year' from the distinctYear collection.
var filter = ee.Filter.equals({leftField: 'year', rightField: 'year'});

// Define a join.
var join = ee.Join.saveAll('sameYear');

// Apply the join and convert the resulting FeatureCollection to an
// ImageCollection.
var joinCol = ee.ImageCollection(
  join.apply(distinctYear, era_min_t, filter)
);
print(joinCol);

1 Answer 1

2

I would iterate over the years, mask non-freezing pixels and count:

var collection = ee.ImageCollection("ECMWF/ERA5/DAILY")
  .select('minimum_2m_air_temperature')
  
var freezingTemperature = 273.15

var freezingYearCount = ee.ImageCollection(ee.List.sequence(1990, 2019)
  .map(function (year) {
    var startDate = ee.Date.fromYMD(ee.Number(year), 1, 1)
    return collection
      .filterDate(startDate, startDate.advance(1, 'year'))
      .map(function (dailyTemperature) {
        return dailyTemperature
          .updateMask( // Mask days that are not freezing
            dailyTemperature.lt(freezingTemperature)
          )
      })
      .reduce(ee.Reducer.count()) // Number of freezing days
      .gte(7) // At least 7 freezing days 
  })
).reduce(ee.Reducer.count()) // Number of freezing years

Map.addLayer(freezingYearCount, {min: 0, max: 30, palette: '#e8fa5b, #fbb43d, #eb7958, #b15f82, #744992, #2c3395'}, 'freezingYearCount')

https://code.earthengine.google.com/ee845e74ee16d5e9039129ced31c5b80

2

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.