2

I want to export the values of NDVI and NDBI for the feature collection.

var data= L8TOA1.filterDate('2019-02-01', '2019-03-28') 
              .filter(ee.Filter.equals('WRS_PATH', 146))
              .filter(ee.Filter.eq('WRS_ROW', 40))
              .sort('CLOUD_COVER').first();
print(data);
//Get cloud cover information
var cloud= data.get('CLOUD_COVER');
print('cloud_cover is',cloud);
//Cip with boundary
var Study_region = data.clipToCollection(aoi);
// Define the visualization parameters.
var colour = {bands: ['B5', 'B4', 'B3'],min: 0,max: 0.5,gamma: 1.4,}
// Add layer to the map
Map.addLayer(Study_region,colour,'FCC');
Map.centerObject(aoi, 9);

//Indice
var NDBI = ee.Image (Study_region.normalizedDifference(['B6', 'B5']).rename('NDBI'));
var NDVI = ee.Image (Study_region.normalizedDifference(['B5', 'B4']).rename('NDVI'));
var SI= NDBI.addBands(NDVI)
print("Stacked_Image",SI);
var viz = [
'#FFFFFF','#808080','#000000','#FF0000', '#800000', '#FFFF00', '#008000', '#00FFFF', '#0000FF', '#FF00FF', '#800080'];
Map.addLayer(NDBI, {min: -1, max: 1, palette: viz},'NDBI');
// Get the Indices values to the point
var VTP = ee.FeatureCollection(SI.select(['NDBI','NDVI'])
  .reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: Urban.geometry(),
  scale: 30
}));
var Urban = Urban.set(VTP) ;
print('a',Urban);
print("Indices values to the point",VTP);
Export.table.toDrive({
collection: Urban,
description :"Indcies",
folder:"GEE",
fileNamePrefix: "Indcies",
fileFormat:"CSV",
selectors:['NDBI','NDVI']
});

When I exported the data, the value of NDBI and NDVI are not exported. Only the names were there exported. 

1 Answer 1

3

You're requesting export of a table. and columns like a database or spreadsheet. In Earth Engine, the “rows” of a table are features, and the “columns” are property names. Each cell contains the value of a property of the row feature.

You computed one value (using reduceRegion) and then put those results as properties of the feature collection, not any of its features using

var Urban = Urban.set(VTP) ;

The properties of the collection are not used in CSV export.

What to do instead depends on what you want.

  • If you want to export just the two values, then you need to create a single feature for them, and put it into a collection, just so you have enough structure for the export to work:

    Export.table.toDrive({
        collection: ee.FeatureCollection([ee.Feature(null, VTP)]),
        ...
    });
    
  • If you want to get the normalized difference values separately for each feature in Urban, then you should use reduceRegions({collection: Urban, ...}) instead of reduceRegion({geometry: Urban.geometry(), ...}). That will return a FeatureCollection with properties added to each feature, which you can then export.

1
  • Thank you, Kevin Reid.
    – Prathiba
    Commented Jan 24, 2020 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.