Google Earth Engine – Calculating Coefficient of Variation Timeseries in Google Earth Engine

google-earth-enginegoogle-earth-engine-javascript-apitime series

You can build a timeseries for mean or standard deviation band values over a geometry in Google Earth Engine (see code below). However, there does not appear to be an option to plot a timeseries of Coefficient of Variation, despite mean and standard deviation reducers being available.

To generate a Coefficient of Variation timeseries, you could generate mean and standard deviation timerseries and calculate the CV for each plot outside of Google Earth Engine, but this seems impractical. Can this calculation be performed from reducers inside Google Earth Engine?

var evoNDvI = ui.Chart.image.seriesByRegion(
  S2,                // Image collection
  geometry,      // Region
  ee.Reducer.mean(), // Type of reducer
  'ndvi',              // Band
  10);               // Scale
  
var plotNDvI = evoNDvI                    // Data
    .setChartType('LineChart')            // Type of plot
    .setOptions({                         // Plot customization
      interpolateNulls: true,
      lineWidth: 1,
      pointSize: 3
});

print(plotNDvI)

Best Answer

This appears to be just the stddev/mean of each image, plotted. Something like this:

var result = S2.map(function(img) {
    var mean = img.select('ndvi').reduceRegion(ee.Reducer.mean(), geometry, scale)
    var stddev = img.select('ndvi').reduceRegion(ee.Reducer.stdDev(), geometry, scale)
    return img.set('cv', stddev.get('stdDev').divide(mean.get('mean'))
})

print(ui.Chart.feature.byFeature(result, 'system:time_start', 'cv'))
Related Question