3

I am using the Copernicus Global land cover layers:CGLS-LC100 collection 3 data set. I want to reclassify the value of the lulc for my application. Map is showing but when I want to reclassify the problem encounter is lulc1.eq is not a function.

// lulc
var lulc1 = ee.ImageCollection("COPERNICUS/Landcover/100m/Proba-V-C3/Global")
.select('discrete_classification');
print(lulc1)
var properties = lulc1.propertyNames();
print('Metadata properties:', properties);
// print(lulc1.bandNames())

Map.addLayer(lulc1, {min: 0, max: 200, palette: ['#282828', '#FFBB22','#FFFF4C'
,'#F096FF','#FA0000','#B4B4B4','#F0F0F0','#0032C8','#0096A0','#FAE6A0',
'#58481F','#009900','#70663E','#00CC00','#4E751F','#007800','#666000','#8DB400'
,'#8D7400','#A0DC00','#929900   ','#648C00','#000080']}, "Land Cover")


print(data)
var lulcreclass = ee.Image(1).where(lulc1.eq(0).and(lulc1.eq(50)), 9)//**problem encounter in this lin**e
           .where(lulc.gt(50).and(lulc.lte(100)), 6)
           .where(lulc.gt(100).and(lulc.lte(150)), 4)
 Map.addLayer(lulcreclass,{},"LULC RECLASS")

1 Answer 1

5

The variable lulc1 is an image collection with 5 elements (images between years 2015 and 2019). If you want to reclassify it, it is preferable to map entire collection with a function. Following code fix up your issues and add your image collection to the Map View of GEE.

// lulc
var lulc1 = ee.ImageCollection("COPERNICUS/Landcover/100m/Proba-V-C3/Global")
  .select('discrete_classification');

print(lulc1);

var properties = lulc1.propertyNames();
print('Metadata properties:', properties);
// print(lulc1.bandNames())

Map.addLayer(lulc1, {min: 0, 
                     max: 200, 
                     palette: ['#282828', '#FFBB22','#FFFF4C','#F096FF','#FA0000',
                     '#B4B4B4','#F0F0F0','#0032C8','#0096A0','#FAE6A0','#58481F',
                     '#009900','#70663E','#00CC00','#4E751F','#007800','#666000',
                     '#8DB400','#8D7400','#A0DC00','#929900','#648C00','#000080']}, 
                     "Land Cover");

var lulcreclass = lulc1.map(function (img) {
  
  return ee.Image(img)
    .where(img.eq(0).and(img.eq(50)), 9)
    .where(img.gt(50).and(img.lte(100)), 6)
    .where(img.gt(100).and(img.lte(150)), 4);
  
});

print(lulcreclass);

Map.addLayer(lulcreclass, {min: 0, 
                     max: 200, 
                     palette: ['#282828', '#FFBB22','#FFFF4C','#F096FF','#FA0000',
                     '#B4B4B4','#F0F0F0','#0032C8','#0096A0','#FAE6A0','#58481F',
                     '#009900','#70663E','#00CC00','#4E751F','#007800','#666000',
                     '#8DB400','#8D7400','#A0DC00','#929900','#648C00','#000080']},
                     "LULC RECLASS");

This can be observed in following picture with the same palette used in lulc1.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.