问题
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 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) - surface area in square km.
How should I go about doing it?
I have created the following code:
var l5 = ee.ImageCollection("LANDSAT/LT05/C01/T1_SR"),
roi = /* color: #d63000 */ee.Geometry.Polygon(
[[[77.68018052033392, 31.0091863423649],
[80.36084458283392, 29.5863837026937],
[80.98706528595892, 30.233944725529557],
[78.85571762970892, 31.57247908795104]]]),
elevation = ee.Image("USGS/SRTMGL1_003"),
l7 = ee.ImageCollection("LANDSAT/LE07/C01/T1_RT_TOA");
var mf = ee.Filter.calendarRange(10, 12, 'month');
Map.centerObject(roi);
var img1 = ee.ImageCollection(l5
.filterDate('1995-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 band function
var addNDWI = function(image) {
return image
// NDWI
.addBands(image.normalizedDifference(['B2', 'B4']).rename('NDWI'))
};
//map add ndwi function to both image collections
var image1 = img1.map(addNDWI);
var image2 = img2.map(addNDWI);
Map.addLayer(image1, {}, 'image1');
Map.addLayer(image2, {}, 'image2');
//masking function for elevation and ndwi
var mask = function(image) {
var ndwiMask = image.select('NDWI').gte(0.3);
var elevMask = elevation.updateMask(elevation.gt(1500));
return image.updateMask(ndwiMask)
return image.updateMask(elevMask);
};
//map masking function
var maskedImg = image1.map(mask); //For 1984-1999
var maskedImg2 = image2.map(mask); //For 2000-2018
print(maskedImg);
print(maskedImg2);
//set up params to view NDWI band
var ndwiViz = {bands: 'NDWI',min: 0.3, palette: ['00FFFF', '0000FF']};
Map.addLayer(maskedImg, ndwiViz, 'NDWI 1984-1999');
Map.addLayer(maskedImg2, ndwiViz, 'NDWI 2000-2018');
The output shows unexpected blue lines in the map display. Also I need to limit the output to the polygon bounded region only but .clip() seems to be not working in this case.
This is the Earth Engine link to the same
来源:https://stackoverflow.com/questions/56862920/how-to-display-changes-in-lakes-surface-area-over-time-in-a-polygon-bounded-reg