My experience and expertise in Google Earth Engine are super low. My study area is Sundarban, Bangladesh. I have 2 NDVI from 2 years (2016 & 2017). I want to find the vegetation change by subtracting these two layers. But my study area also contains unwanted water bodies. So, I need to calculate vegetational changes by excluding water bodies. After calculating the difference I need a layer of this changed vegetative area.
Any kind soul to help me out solving this problem?
/// Masking clouds
// // Create the cloud masking function.
var maskClouds = function(image){
var cloudScore = ee.Algorithms.Landsat.simpleCloudScore(image);
var cloudLikelihood = cloudScore.select('cloud');
var cloudPixels = cloudLikelihood.lt(cloud_thresh);
return image.updateMask(cloudPixels);
};
////For 2016 image
var landsat8_collection_2016 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterBounds(Sundarban)
.filterDate('2016-01-01', '2016-01-31');
var landsat8_collection_2016_NoClouds = landsat8_collection_2016.map(maskClouds);
// Reduce the collection to the median value per pixel.
var median_L8_2016 = landsat8_collection_2016_NoClouds.median()
.clip(Sundarban);
// Create an NDVI image using bands the NIR and red bands (5 and4) for 2016.
var NDVI = median_L8_2016.normalizedDifference(['B5', 'B4']);
////For 2016 image
var landsat8_collection_2017 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterBounds(Sundarban)
.filterDate('2017-01-01', '2017-01-30');
var landsat8_collection_2017_NoClouds = landsat8_collection_2017.map(maskClouds);
.filterDate('2017-01-01', '2017-01-30');
// // Reduce the collection to the median value per pixel.
var median_L8_2017 = landsat8_collection_2017_NoClouds.median()
.clip(Sundarban);
// Create an NDVI image using bands the NIR and red bands (5 and4) for 2017.
var NDVI17 = median_L8_2017.normalizedDifference(['B5', 'B4']);