I want to export image to drive for my roi. For this i have specified a geometry(roi). But exported map doesn't cover the area specified and it's not showing the color palette. Is there any possible way to export a colored image (which shows in my layer) to Drive? Why it's not covering the region I have specified. Problem is in export.To.Drive section. But all the codes are given to check error that i did.
Code was:
var region = ee.FeatureCollection('users/karmakersourav/shape')
.filter(ee.Filter.eq('NAME_1', 'Chittagong'));
var addNDVI = function(image) {
var ndvi= image.normalizedDifference(['B4', 'B3']).rename('NDVI');
return image.addBands(ndvi);
};
var cloudMask = function(image) {
var clouds = ee.Algorithms.Landsat.simpleCloudScore(image).select(['cloud']);
return image.updateMask(clouds.lt(25));
};
// Select the land mask.
var landMask = function(image) {
var datamask = hansenImage.select('datamask');
// Create a binary mask.
var mask = datamask.eq(1);
return image.updateMask(mask);
};
// Load a Landsat collection, apply the NDVI and cloud/water masking functions over it.
var collection1 = ee.ImageCollection('LANDSAT/LE07/C01/T1_RT_TOA')
.filterBounds(region)
.filterDate('2008-01-01','2008-12-31')
.map(addNDVI)
.map(cloudMask)
.map(landMask)
.select('NDVI') ;
print(collection1);
//reducer
var annualNDVI = collection1.reduce(ee.Reducer.median());
var region_NDVI = annualNDVI.reduceRegions({
collection: region,
reducer: ee.Reducer.median(),
scale: 30 // the resolution of the dataset
});
var ndviParams = {min: -1, max: 1, palette: ['blue', 'white','green']};
var boundParams = {palette: ['black']};
Map.addLayer(annualNDVI.clip(region), ndviParams, 'NDVI', 1);
Map.addLayer(region, boundParams, 'LA', 1);
//here's the problem
Export.image.toDrive({
image: annualNDVI,
description: 'CTG_NDVi',
scale: 30,
region: roi,
fileFormat: 'GeoTIFF',
maxPixels: 1e12,
formatOptions: {
cloudOptimized: true
}
});
My imports was:
var image = ee.Image("UMD/hansen/global_forest_change_2015_v1_3"),
region = ee.FeatureCollection("users/karmakersourav/shape"),
hansenImage = ee.Image("UMD/hansen/global_forest_change_2015"),
roi = /* color: #98ff00 */ee.Geometry.Polygon(
[[[91.26571433292804, 22.382447200369512],
[91.70516745792804, 22.24015355729955],
[91.81503073917804, 21.50608889294255],
[91.99081198917804, 21.158146277513005],
[92.36434714542804, 20.74775339022756],
[92.38631980167804, 21.362918378188724],
[92.68868864595584, 21.285515736407884],
[92.66671598970584, 22.12251851402064],
[92.42501677095584, 22.964696114885136],
[92.43600309908084, 23.237540932485988],
[92.31515348970584, 23.620600408965007],
[92.21627653658084, 23.781555321668222],
[92.04049528658084, 23.691042604440895],
[91.90865934908084, 23.731278240693108],
[91.89767302095584, 23.47960242153599],
[91.75485075533084, 23.28800680321665],
[91.77682341158084, 23.08602889002461],
[91.61202848970584, 22.99503954262493],
[91.46920622408084, 23.277915158047364],
[91.34835661470584, 23.308187798303887],
[91.22750700533084, 23.600467103459394],
[91.28243864595584, 23.872005072934794],
[91.32638395845584, 24.082808607079368],
[91.24947966158084, 24.263221977268092],
[91.06271208345584, 24.223152164577193],
[90.73312223970584, 23.88205115062075],
[90.63424528658084, 23.660857737733508],
[90.54635466158084, 23.328365731356676],
[90.65621794283084, 22.83312931280329],
[90.98580778658084, 22.437667249990497],
[90.98580778658084, 22.071621721722586]]]);