0

I've been working on a classification scheme, and have 6 different classes i wish to map. Everything has been already done in terms of finding the classifications. the only thing I am struggling on now is how to import all 6 classes (6 classes but 7 vars) onto the same map, without them going on top of one another.

My end goal is for it to look like this:

Code used:

var image = ee.Image(landsat.filterDate ('2018-01-01', '2018-03-01').filterBounds(point).sort('CLOUD_COVER').first());

//print image 
print('a landsat scene', image);

//define parameters

var green = image.select('B3');
var swi = image.select('B6');
var mndwi = green.subtract(swi).divide(green.add(swi)).rename('MNDWI');

var mndwipara = {min: 0, max: 0.7, palette: ['white', 'blue']};


Map.addLayer(mndwi, mndwipara, 'MNDWI');


//apply threshold to select only positive pixels 
var lake_mask= mndwi.gt(0);
Map.addLayer(lake_mask);

//image reducer
var meanDictionary =image.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: image.geometry(),
scale: 30,
maxPixels: 1e9
});
// The result is a Dictionary.  Print it.
print(meanDictionary);

//classification attempt - scum
var scum=image.expression(
'(nir)*0 + (nir < 0.018)*1', {
'nir': image.select('B5'),
'red': image.select ('B4'),
'green': image.select('B3'),
});

 //classification attempt - sediment
var sediment=image.expression(
'(nir)*0 + (nir > 0.018 && red > green && green/nir < 1.3 && red/green> nir/red)*1', {
'nir': image.select('B5'),
'red': image.select ('B4'),
'green': image.select('B3'),
});

//classification attempt - lowbiomass
var lowbiomass=image.expression(
'(nir)*0 + (nir > 0.018 && red < green && green > 0.065 && nir < red)*1', {
'nir': image.select('B5'),
'red': image.select ('B4'),
'green': image.select('B3'),
});


//classification attempt-scum
var scum=image.expression(
'(nir)*0 + (nir > 0.018 && red < green && green > 0.065 && nir > red && nir/red > 4.07)*1', {
'nir': image.select('B5'),
'red': image.select ('B4'),
'green': image.select('B3'),
  });

 //classifcation attempt bleached scum
  var bleached_scum=image.expression(
  '(nir)*0 + (nir > 0.018 && red > green && green/nir > 1.3 && green > 0.065)*1', {
'nir': image.select('B5'),
'red': image.select ('B4'),
'green': image.select('B3'),
});

//classification attempt - microphytobenthos
var microphytobenthos=image.expression(
'(nir)*0 + (nir > 0.018 && red > green && green/nir < 1.3 && red/green< nir/red)*1', {
'nir': image.select('B5'),
'red': image.select ('B4'),
'green': image.select('B3'),
});

//classification attempt - highbiomass
var highbiomass=image.expression(
'(nir)*0 + (nir > 0.018 && red < green && green > 0.065 && nir > red && nir/red < 4.07)*1', {
'nir': image.select('B5'),
'red': image.select ('B4'),
'green': image.select('B3'),
 });
  • were you able to developed the multi-layered classification map for each object using the predictor algorithms? I don't think the example @aldo_tapia is what you were attempting to produce. Have you been successful in completing the classifier? If so, do you mind sharing it with me. Kind Regards, – ryan.cant Sep 18 '18 at 17:26
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – csk Sep 18 '18 at 17:50
  • Hi @Isaaqm, The predictors are not registering. This is likely due to an error in the expression. – ryan.cant Sep 18 '18 at 18:26
1

You should try to create images with classification values and reduce them to a unique image. Something like:

/*
lake = 1
scum = 2
bleached scum = 3
microphytobenthos = 4
highbiomass = 5
*/

var lake_mask_ = ee.Image(1).mask(lake_mask).toInt();
var scum_ = ee.Image(2).mask(lake_mask.mask(scum)).toInt();
var bleached_scum_ = ee.Image(3).mask(lake_mask.mask(bleached_scum)).toInt();
var microphytobenthos_ = ee.Image(4).mask(lake_mask.mask(microphytobenthos)).toInt();
var scum_ = ee.Image(5).mask(lake_mask.mask(highbiomass)).toInt();

var test = ee.ImageCollection([lake_mask_,scum_,bleached_scum_,microphytobenthos_,scum_]);

var test = test.reduce(ee.Reducer.max());

print(test);  
Map.addLayer(test,{min: 1, max: 5, palette: ['0000FF', 'F4FF0B','430081','FA0007','1BCFFF']},'Classification');

Link to example: https://code.earthengine.google.com/eb49d6959f5ac8f0711751ab01e87001

Also, mask clouds first

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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