0

The problem statement is that a region of interest is given.

I need to find all the lakes in a polygon bounded region using the NDWI index for water bodies, which are at a height of more than 1500m. Then display the changes in the area of lake's surface water starting from the year 1984 till 2018 on a 2-year interval in a table like structure in Google Earth Engine. I have used Landsat 5 and 7 data.

I have created the following code: Earth Engine Code

Now I need to display the results in the polygon marked region in a table sort of structure in the following format:- Rows - (Lake 1, Lake 2, Lake 3... Lake n) Columns - (Surface Area in 1984, Surface Area in 1986, ....2018)

How should I go about doing it?

Rudradeep Deb
  • 41
  • 1
  • 5

1 Answers1

0

I answer this question in regard of the code posted in the comments, hopefully the question is updated with the code posted in the comments.

Filtering: ok.

Just a comment, I wouldn't name an image collection variable with name img, it's just confusing to me, but variables names are up to you.

var mf = ee.Filter.calendarRange(10, 12, 'month');

var img1 = ee.ImageCollection(l5
            .filterDate('1984-01-01','1999-12-31')
            .filterBounds(roi)
            .filter(mf));

var img2 = ee.ImageCollection(l7
            .filterDate('2000-01-01','2018-12-31')
            .filterBounds(roi)
            .filter(mf));

add NDWI: This is your code:

var addNDWI = function(image){
  var ndwi = image.normalizedDifference(['B2', 'B4']).rename('NDWI');
  var ndwiMask = ndwi.gte(0.3);
  return image.addBands(ndwi);
};
var image1 = img1.map(addNDWI);
var image2 = img2.map(addNDWI);

you are not saving ndwiMask, so you won't be able to use it outside of this function. Again, I wouldn't name them image as they are not images but image collections.

elevation mask: you have to select the elevation band:

var elevMask = elevation.select('elevation').gt(1500)

This mask image will have ones where elevation is greater than 1500 and zeros where not.

applying masks: in this part you have to remember that Earth Engine uses functional programming, so objects are not mutable, this means that you cannot update the state of an object using a method, you have to catch the output of the method you are calling. Here you need ndwi mask, so you have to compute it with NDWI band.

var mask = function(image){
  var ndwiMask = image.select('NDWI').gt(0.3)
  var ndwi_masked = image.updateMask(ndwiMask);
  return ndwi_masked.updateMask(elevMask);
};

var maskedImg = image1.map(mask);  // ImageCollection!
var maskedImg2 = image2.map(mask);  // ImageCollection!

Visualizing: As the results are ImageCollection, when you add it to the map EE makes a mosaic and that is what you would see. Keep that in mind for further processing.

var ndwiViz = {bands: ['NDWI'], min: 0.5, max: 1, palette: ['00FFFF', '0000FF']};
Map.addLayer(maskedImg, ndwiViz, 'Landsat 5 masked collection');
Rodrigo E. Principe
  • 1,281
  • 16
  • 26
  • Updated the code a bit. Also added the updated link to the code in the question. Now I need to display the changes in the area of lake's surface water starting from the year 1984 till 2018 on a 2-year interval in a table like structure in Earth Engine. Also could you please check the display on the map? – Rudradeep Deb Jul 02 '19 at 05:11
  • but this this answer the original question?? you should not update the question making a new question. Keep the original question here and make another post if required – Rodrigo E. Principe Jul 02 '19 at 11:26
  • Here is the new question : https://stackoverflow.com/q/56862920/9937666 . Please check it out. – Rudradeep Deb Jul 03 '19 at 04:29