Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var L8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA")
- .filterDate('2016-06-01', '2016-07-31') // you can change date here
- .filter(ee.Filter.lt("CLOUD_COVER", 0.75))
- .filterBounds(collection[i])
- .map(maskLandsatclouds)
- .sort('DATE_ACQUIRED')
- .select(L8bands)
- var count = L8.size();
- for (var j=0;j< 10 ;j++){
- // Get the number of images.
- print(j);
- var mosaic_L8 =L8.median().clip(collection[i]); // here we are taking the
- median at each pixel in the collection
- Map.addLayer(mosaic_L8, L8vis, "mosaic_L8")
- // Create an NDWI image, define visualization parameters and display.
- var ndwi = mosaic_L8.normalizedDifference(['B3', 'B5']);
- var ndwiViz = {min: 0.5, max: 1, palette: ['44c9f1', '1637f1']};
- //Map.addLayer(ndwi, ndwiViz, 'NDWI', false);
- // Mask the non-watery parts of the image, where NDWI < 0.10.
- var ndwiMasked = ndwi.updateMask(ndwi.gte(0.10));
- Map.addLayer(ndwiMasked, ndwiViz,'NDWI masked '+ ee.Number(j).getInfo());
- Map.centerObject(ndwiMasked);
- // // NDWI expression
- var ndwiL8 = mosaic_L8.expression(
- '(G - NIR) / (G + NIR)' , {
- 'NIR' : mosaic_L8.select('B5'),
- 'G' : mosaic_L8.select('B3')
- } ) ;
- // NDWI math operation
- var ndwi_L8 = mosaic_L8.select('B3').subtract(mosaic_L8.select('B5'))
- .divide(mosaic_L8.select('B3').add(mosaic_L8.select('B5')));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement