Spectral signature of classified image in GEE using Random Forest

I am using this script to draw average spectral signature of all classes together and each class separately of a classified image by RF algorithm in GEE.

var bands = ['B1', 'B2', 'B3', 'B4','B5','B6','B7', 'B8', 'B8A', 'B9' ,'B11', 'B12','NDVI', 'EVI', 'GNDVI', 'NBR', 'NDII'];
var Training_Points = Water.merge(Residential).merge(Agricultural).merge(Arbusti).merge(BoschiMisti).merge(Latifoglie).merge(Conifere).merge(BareSoil);
var classes = ee.Image().byte().paint(Training_Points, "land_class").rename("land_class")


var stratified_points = classes.stratifiedSample({
      numPoints: 50,
      classBand: 'land_class',
      scale: 10,
      region: Training_Points,
      geometries: false,
      tileScale: 6
})

print(stratified_points, 'stratified_points')


//Create training data
var training_Stratified = RF_classified.select(bands).sampleRegions({
  collection: stratified_points,
  properties: ['land_class'],
  scale:10,
  tileScale:2
});


var bands = RF_classified.bandNames()
var numBands = bands.length()
var bandsWithClass = bands.add('land_class')
var classIndex = bandsWithClass.indexOf('land_class')

// Use .combine() to get a reducer capable of computing multiple stats on the input
var combinedReducer = ee.Reducer.mean().combine({
  reducer2: ee.Reducer.stdDev(),
  sharedInputs: true})

// Use .repeat() to get a reducer for each band and then use .group() to get stats by class
var repeatedReducer = combinedReducer.repeat(numBands).group(classIndex)

var stratified_points_Stats = training_Stratified.reduceColumns({
    selectors: bands.add('land_class'),
    reducer: repeatedReducer,
})

// Result is a dictionary, we do some post-processing to extract the results
var groups = ee.List(stratified_points_Stats.get('groups'))

var classNames = ee.List(['Water','Residential', 'Agricultural', 'Arbusti', 'BoschiMisti', 'Latifoglie','Conifere', 'BareSoil'])

var fc = ee.FeatureCollection(groups.map(function(item) {
  // Extract the means
  var values = ee.Dictionary(item).get('mean')
  var groupNumber = ee.Dictionary(item).get('group')
  var properties = ee.Dictionary.fromLists(bands, values)
  var withClass = properties.set('class', classNames.get(groupNumber))
  return ee.Feature(null, withClass)
}))

// Chart spectral signatures of training data
var options = {
  title: 'Average Spectral Signatures',
  hAxis: {title: 'Bands'},
  vAxis: {title: 'Reflectance', 
    viewWindowMode:'explicit',
    viewWindow: {
        max:6000,
        min:0
    }},
  lineWidth: 1,
  pointSize: 4,
  series: {
    0: {color: '105af0'},                                   
    1: {color: 'dc350a'}, 
    2: {color: 'caa712'}, 
    3: {color: 'b9ffa4'},
    4: {color: '369b47'},
    5: {color: '21ff2d'},
    6: {color: '275b25'},
    7: {color: 'f7e084'},   
}};

// Default band names don't sort propertly Instead, we can give a dictionary with labels for each band in the X-Axis
var bandDescriptions = {
  'B2': 'B2/Blue',
  'B3': 'B3/Green',
  'B4': 'B4/Red',
  'B5': 'B5/Red Edge 1',
  'B6': 'B5/Red Edge 2',
  'B7': 'B7/Red Edge 3',
  'B8': 'B8/NIR',
  'B8A': 'B8A/Red Edge 4',
  'B11': 'B11/SWIR-1',
  'B12': 'B12/SWIR-2'
}

// Create the chart and set options.
var chart = ui.Chart.feature.byProperty({
  features: fc,
  xProperties: bandDescriptions,
  seriesProperty: 'class'
})
.setChartType('ScatterChart')
.setOptions(options);

print(chart)

var classChart = function(land_class, label, color) {
  var options = {
  title: 'Spectral Signatures for ' + label + ' Class',
  hAxis: {title: 'Bands'},
  vAxis: {title: 'Reflectance', 
    viewWindowMode:'explicit',
    viewWindow: {
        max:6000,
        min:0
    }},
  lineWidth: 1,
  pointSize: 4,  
  };

  var fc = training_Stratified.filter(ee.Filter.eq('land_class', land_class))
  var chart = ui.Chart.feature.byProperty({
  features: fc,
  xProperties: bandDescriptions,
  })
.setChartType('ScatterChart')
.setOptions(options);

print(chart)
}
classChart(0, 'Water')
classChart(1, 'Residential')
classChart(2, 'Agricultural')
classChart(3, 'Arbusti')
classChart(4, 'BoschiMisti')
classChart(5, 'Latifoglie')
classChart(6, 'Conifere')
classChart(7, 'BareSoil')

I receive the error:

Error generating chart: Image.select: Pattern 'B1' did not match any bands.

I do not understand where is the problem since I used the same script before to draw histogram of training data and it worked well.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum