I can export NDVI values to CSV file. But I couldn't export RGB values(b2,,b3,b4) to csv file and RGB values must be in range 0-255.
var geometry =
/* color: #d63000 */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[26.9559366037084, 39.42848463948233],
[26.9559366037084, 39.41562180312237],
[26.971214466257226, 39.41562180312237],
[26.971214466257226, 39.42848463948233]]], null, false);
var image = ee.Image(ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterBounds(geometry)
.filterDate('2020-06-01', '2020-8-31')
.filterMetadata('CLOUD_COVER','less_than',5)
.sort('CLOUD_COVER')
.first());
var palette = [
'FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718',
'74A901', '66A000', '529400', '3E8601', '207401', '056201',
'004C00', '023B01', '012E01', '011D01', '011301']
function addNdvi(img){
var ndvi = img.normalizedDifference(['B5','B4']).rename('ndvi');
return img.addBands(ndvi);
}
var ndvi= addNdvi(image.clip(geometry));
Map.addLayer(ndvi,{bands: ['ndvi'], palette: palette},'ndvi');
Map.addLayer(image.clip(geometry),{bands: ['B4', 'B3', 'B2'], max:0.3}, 'rgb');
var ndviFeatures = ee.FeatureCollection(ee.List(ndvi
.reduceRegion({
reducer: ee.Reducer.toList(),
geometry: geometry,
scale: 10
})
.get('ndvi'))
.map(function (ndvi) {
return ee.Feature(null, {ndvi: ndvi})``
})
)
var rgbFeatures = ee.FeatureCollection(ee.List(image
.reduceRegion({
reducer: ee.Reducer.toList(),
geometry: geometry,
scale: 10
})
.get('image'))
.map(function (rgb) {
return ee.Feature(null, {rgb: rgb})
})
)
print('# rgb of pixels',rgbFeatures.size())
print('# ndvi of pixels',ndviFeatures.size())
Export.table.toDrive({
collection: rgbFeatures,
description: 'dene',
fileFormat: 'CSV',
selectors: ['B4', 'B3', 'B2']
});
Export.table.toDrive({
collection: ndviFeatures,
description: 'ndvi',
selectors: ['ndvi']
})