Skip to main content
nam,ing; formatting
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

Cannot export rgbRGB values to csvCSV

I can export ndviNDVI values to csvCSV file. But I couldn't export rgbRGB values(b2,,b3,b4) to csv file and rgbRGB 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']
})
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']
})

Cannot export rgb values to csv

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']
})

Cannot export RGB values to CSV

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']
})
added 337 characters in body; edited tags; edited title
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

i cant get Cannot export rgb values to csv

iI can export ndvi values to csv file. But i didn'tI 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'] })

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']
})

i cant get rgb values to csv

i can ndvi values to csv file. But i didn't 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'] })

Cannot export rgb values to csv

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']
})
Source Link

i cant get rgb values to csv

i can ndvi values to csv file. But i didn't 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'] })