How to generate box plots for all bands individually as well as overall box plot for all bands in GEE using Javascript

This is the link to my code https://code.earthengine.google.com/5dd7c3096ba4e3401f805084651d979f This is my code:

//landsat 8 SR 2020 annual median image of year 2020 
var myimage= ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
                .select(['B1','B2', 'B3', 'B4', 'B5', 'B6','B7','B10','B11'])

// Get information about the bands as a list.
var bandNames = myimage.bandNames();
print('Band names:', bandNames);  // ee.List of band names

// map a function over the list of band names

var fc = ee.FeatureCollection(bandNames.map(function(band) {
  var image = myimage.select([band])
  var combinedReducer = ee.Reducer.mean()
    .combine({reducer2: ee.Reducer.median(), sharedInputs: true})
    .combine({reducer2: ee.Reducer.mode(),sharedInputs: true})
    .combine({reducer2: ee.Reducer.variance(),sharedInputs: true})
    .combine({reducer2: ee.Reducer.min(),sharedInputs: true})
    .combine({reducer2: ee.Reducer.max(),sharedInputs: true})
    .combine({reducer2: ee.Reducer.kurtosis(),sharedInputs: true})
    .combine({reducer2: ee.Reducer.stdDev(),sharedInputs: true})
    .combine({reducer2: ee.Reducer.skew(),sharedInputs: true});

  var stats = image.reduceRegion({
    reducer: combinedReducer,
    geometry: polygon,
    scale: 90
  var meanKey = ee.String(band).cat('_mean')
  var medianKey = ee.String(band).cat('_median')
  var modeKey = ee.String(band).cat('_mode')
  var varianceKey= ee.String(band).cat('_variance')
  var minKey=ee.String(band).cat('_min')
  var maxKey=ee.String(band).cat('_max')
  var kurtosisKey=ee.String(band).cat('_kurtosis')
  var skewKey=ee.String(band).cat('_skew')
  var properties = {
    'band': band,
    'mean': stats.get(meanKey),
    'median': stats.get(medianKey),
    'mode': stats.get(modeKey),
    'variance': stats.get(varianceKey),
    'minimum': stats.get(minKey),
    'maximum': stats.get(maxKey),
    'kurtosis': stats.get(kurtosisKey),
    'skew': stats.get(skewKey)

  return ee.Feature(null, properties)

// print the results

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.