1

I wrote this code in Google Earth Engine to perform unsupervised classification. The code seems to work fine. I need to classify conifer trees specifically between all other land covers and I need the spectral signatures of each class to evaluate them and recognize conifers. Is there a way in GEE to calculate and plot the epectral signature of each class?

     // UNSUPERVISED classification of Conifers//
var input = ee.ImageCollection("COPERNICUS/S2_SR");

var geometry = 
    /* color: #98ff00 */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[7.582719257752308, 46.02568420992065],
          [7.582719257752308, 44.97372238809936],
          [9.228269435087903, 44.97372238809936],
          [9.228269435087903, 46.02568420992065]]], null, false);
          

input = input.filterBounds(geometry);

input = input.filterDate('2020-08-06','2020-08-08');

input = input.sort('CLOUD_COVER');

input = input.mosaic();

input = input.clip(geometry);
print(input);

Map.centerObject(geometry,9);  

Map.addLayer(input,{min:-157.33,max:1421.15,bands:['B4','B3','B2']}, 'input image');

var training = input.sample({
  region: geometry,
  scale: 10,
  numPixels: 5000
});

var clusterer = ee.Clusterer.wekaKMeans(15).train(training);

var result =  input.cluster(clusterer);

Map.addLayer(result.randomVisualizer(), {}, 'Unsupervised Classified Image');

Export.image.toDrive({
  image: result,
  description: 'Unsupervised Classified Image',
  scale: 10,
  region: geometry
});

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.