1

I am attempting to implement a classification based from a decision tree (attached as image below) where there are 5 classes. These classes are based off the different water reflectance values in Landsat 8 bands (namely NIR, Red and Green). I have no idea how I should go about doing this. Someone suggested using image.expression however it has not worked for me. This is the code I've used thus far: (landsat is landsat 8 surface reflection)

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);

//implement MNDWI

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

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


Map.addLayer(mndvi, mndvipara, 'MNDVI image');

//classification attempt 
var lpb =image.expression (
'nir > 0.018', {
'nir': image.select ('B5')});
Map.addLayer (lpb, {min: -1, max: 1, palette: ['FF0000', '00FF00']});

[1]: https://i.stack.imgur.com/TKSbZ.png (if image doesn't work, classification can be found at https://www.sciencedirect.com/science/article/pii/S0303243415000641 - Figure A.1

  • What exactly did not work? Is the result unexpected, did you receive an error message or is there an issue with the .expression() function? – Kersten Mar 6 '18 at 14:39
  • Check this example to know how to use GGE decision tree – aldo_tapia Mar 6 '18 at 15:05
1

Yes, you can use ee.Image.expression() to implement a classification decision tree. Although it is unclear which Landsat 8 image collection you are using, if it is the Landsat 8 Surface Reflectance collection you will need to include the scaling factor in the calculation:

var lpb = image.expression(
  'nir > 0.018', 
  {
    'nir': image.select('B5').multiply(0.0001)
  }
);

While using ee.Image.expression() will work, it may be cleaner to implement this decision tree using a series of conditional or boolean operators.

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.