0

I want to stack layers of 3 images (median images from 3 seasons). I want to differentiate the land uses in different seasons. for example, there will be more waterbodies in rainy season but less in summer. I want to delineate the disappeared waterbodies in summer and define those as wetlands. The waterbodies remains all through the year will be regarded as waterbody. I have tried using "add", "subtract" and "mask" function to do that. It didn't work.

My codes:

var maskL8 = function(image_m) {
  var qa = image_m.select('BQA');
  var mask = qa.bitwiseAnd(1 << 4).eq(0);
  return image_m.updateMask(mask);
};

var image_m = ee.Image(ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterBounds(roi)
.filterDate('2018-06-16', '2018-10-15')
.map(maskL8)
.median());
Map.addLayer(image_m, {bands: ['B5', 'B4', 'B3'], max: 0.3}, 'image_m');

var maskL8 = function(image_s) {
  var qa = image_s.select('BQA');
  var mask = qa.bitwiseAnd(1 << 4).eq(0);
  return image_s.updateMask(mask);
};

var image_s = ee.Image(ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterBounds(roi)
.filterDate('2018-03-16', '2018-05-15')
.map(maskL8)
.median());
Map.addLayer(image_s, {bands: ['B5', 'B4', 'B3'], max: 0.3}, 'image_s');

var maskL8 = function(image_w) {
  var qa = image_w.select('BQA');
  var mask = qa.bitwiseAnd(1 << 4).eq(0);
  return image_w.updateMask(mask);
};

var image_w = ee.Image(ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterBounds(roi)
.filterDate('2017-11-16', '2018-02-15')
.map(maskL8)
.median());
Map.addLayer(image_w, {bands: ['B5', 'B4', 'B3'], max: 0.3}, 'image_w');

var stacked = image_m.subtract(image_s);
print('stacked_composite bands', stacked.bandNames());
var stacked_all = stacked.subtract(image_w);
print('stacked_composite bands', stacked_all.bandNames());
Map.addLayer(stacked_all, {bands: ['B4', 'B3', 'B2'], max: 0.3}, 'stacked_all');
  • If I understand correctly, you want to combine 3 images image_m, image_s, image_w (each has 3 bands B5, B4, B3) into 1 image? So the resulted image will have 9 bands? – Kevin Jul 20 at 1:13
  • I want to use 3 images to find the land use differences of different seasons. I don't know whether combine (.add) may do that. I think there should be some algorithms for that. For example which places will represent water in 3 images will be defined in a specific class. Which places will show water in one or two season out of three will be excluded from that class and will be defined in a different class. – Shihab Nur Jul 20 at 16:59
  • So you already have 3 images each shows whether a pixel is water or not, and want to classify land use based on the frequency of being water? – Kevin Jul 21 at 3:42
  • Yes. I can classify each image separately. I want to merge them into one image and then classify them in a way so that, waterbodies existing all through the year will be classified as waterbody. Water body transforms into other land uses in any parts of the year will be classified differently. Can you please help me on which algorithm and function I have to use for that. – Shihab Nur Jul 22 at 17:52

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.