I would like to analyze NDVI in the region of Bangkok.
Here is the code :
{
//Define time range
var startyear = 2006;
var endyear = 2016;
//Set date in ee date format
var startdate = ee.Date.fromYMD(startyear, 1, 1);
var enddate = ee.Date.fromYMD(endyear, 12, 31);
///Import a fusion table of your study area
// The Ca basin
var Ca = ee.FeatureCollection(geometry)
//filter on date and area (bounds)
var l5images = l5.filterDate(startdate,enddate).filterBounds( Ca);
var l7images = l7.filterDate(startdate,enddate).filterBounds( Ca);
var l8images = l8.filterDate(startdate,enddate).filterBounds( Ca);
///Include a funtion to remove the clouds
//set cloud threshold
var cloud_threshold = 40;
// Select the red and NIR bands
l5images = l5images.select(["B4","B3"]);
l7images = l7images.select(["B4","B3"]);
l8images = l8images.select(["B5","B4"]);
// calculate ndvi from landsat 8
function l8ndvi(img) {
var ndvi = img.normalizedDifference(['B5', 'B4']).rename('NDVI');
return img.addBands(ndvi);
}
// calculate ndvi from landsat 5 & 7
function l57ndvi(img) {
var ndvi = img.normalizedDifference(['B4', 'B3']).rename('NDVI');
return img.addBands(ndvi);
}
// calculate ndwi for each image in imagecollection
var l5ndvi = l5images.map(l57ndvi);
var l7ndvi = l7images.map(l57ndvi);
var l8ndvi = l8images.map(l8ndvi);
// combine all data in single image collection
var allcollection = ee.ImageCollection((l5ndvi.merge(l7ndvi)).merge(l8ndvi));
// add map to canvas
Map.addLayer(allcollection);
Map.centerObject(allcollection,8);
print()
}
Google Earth Engine Link that I used
But then there is trouble, but I don't really understand what is it about.
So Is there anything I can do about this. I am still very new to programming.