Google Earth Engine – Calculating Pixel Area with ESA WorldCover 10m v100

google-earth-enginegoogle-earth-engine-javascript-api

I am using the 'ESA WorldCover 10m v100' dataset in Google Earth Engine and I am trying to calculate the area that each land cover classification covers in a region I specify. However, I don't know how to extract that band information from the dataset.

I only have the following code so far (since all attempts to do this have failed):

var dataset = ee.ImageCollection("ESA/WorldCover/v100").first();

var visualization = {
  bands: ['Map'],
};

Map.centerObject(area);

Map.addLayer(dataset.clip(area), visualization, "Landcover");

Best Answer

Another way would be by using groupReducers

var dataset = ee.ImageCollection("ESA/WorldCover/v100").first();

var areaImage = ee.Image.pixelArea().addBands(
      dataset)

var areas = areaImage.reduceRegion({
      reducer: ee.Reducer.sum().group({
      groupField: 1,
      groupName: 'landcover_class',
    }),
    geometry: area,
    scale: 10,
    maxPixels: 1e13
    }); 

as referenced here