0

I am currently working with MODI's land surface temperature image collection dataset of 20 years of data. I want to convert each image to a single value representation using mean/max function. I tried the map function, but it returns only images, whereas I am looking for a vector of float values where each value is the max/mean of the temperature of that region.

How can I solve this issue?

1 Answer 1

0

You are on the right track with map(). Hopefully this code explains how you can do this:

// Your area of interest
var region = ee.Geometry.Point([12.492362, 41.890232]).buffer(500).bounds()

// Some collection of images. You're using MODIS here
var imageCollection = ee.ImageCollection('COPERNICUS/S2')
  .filterDate('2019-01-01', '2019-02-01')
  .filterBounds(region)

// A feature collection where each feature contains
// mean and max of each image in the image collection
var featureCollection = imageCollection.map(toMeanMax)
print(featureCollection)

// Calculates mean and max for an image
function toMeanMax(image) {
  var meanMax = image.reduceRegion({
     // Reduce the image to mean and max. Can be done separately,
     // but combining two reducers is more efficient.
    reducer: ee.Reducer.mean()
      .combine(ee.Reducer.max(), null, true),
    geometry: region, // The area of the image you want to reduce
    scale: 10 // The resolution in meters to use
  })
  // When mapping over a collection you must return an 
  // image (map function returns an image collection)
  // or a feature (map function returns a feature collection)
  return ee.Feature(null, meanMax) 
}

https://code.earthengine.google.com/68a509283944836705afc9dd989f92e6

Your Answer

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

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