I am trying to perform an OBIA classification and followed a tutorial but I get the following error : Image.select: Pattern 'B8' did not match any bands which I don't understand because I am selecting bands. Here is the code below.
I am new to coding and did not find much info on OBIA on GEE.
//Object-based classification
// Segmentation -----------------------------------------------------------------------------
var bands = ['B8', 'B4', 'B3','B2'];
var seeds = ee.Algorithms.Image.Segmentation.seedGrid(35);
var snic = ee.Algorithms.Image.Segmentation.SNIC({
image: maskedcomposite,
compactness: 0,
connectivity: 4,
neighborhoodSize: 128,
size: 20,
seeds: seeds
}).select(['B8_mean','B4_mean','B3_mean','B2_mean',"clusters"],['B8', 'B4', 'B3', 'B2', "clusters"]);
var clusters_snic = snic.select("clusters");
Map.addLayer(clusters_snic.randomVisualizer(),{}, 'clusters')
print(clusters_snic,"clusters_snic")
var objectPropertiesImage = ee.Image.cat([
clusters_snic.select(bands),
]).float();
print(objectPropertiesImage,'oPI')
var newfc = geometry.merge(nonfracking)//.merge(roads).merge(Agriculture);
var bands = objectPropertiesImage.bandNames();
var training = maskedcomposite.select(bands).updateMask(seeds).sampleRegions({
collection: newfc,
properties: ['landcover'],
scale: 20,
geometries:true
});
//var training = objectPropertiesImage.addBands(cdl2016.select('cropland'))
// .updateMask(seeds)
//.sample(geometry, 5);
var classifier = ee.Classifier.smileRandomForest(50).train(training, 'OBIA_classification');
Map.addLayer(objectPropertiesImage.classify(classifier), {min:0, max:254}, 'OBIA_classification');
I've checked by printing "masked composite" and it shows 24 bands with the names I am then using. However, it seems like I lose them when I select clusters, how can I solve this because all the obia tutorials I saw used clusters at this stage.