TransWikia.com

Extract multiple indices values to the Feature collection in Google Earth Engine and export it as CSV File

Geographic Information Systems Asked by Prathiba on April 14, 2021

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);
//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 feature = ee.FeatureCollection([(Urban),(Vegetation)]);
print("Feature_points",feature);
//Extract values to the multiple points in different features
var img = SI.select(['NDBI','NDVI'])
 .reduceRegions({
   collection: feature,
   reducer: ee.Reducer.toList()});
print("Feature properties",img);
Export.table.toDrive({
   collection: img,
   description :"Indcies",
   folder:"GEE",
   fileNamePrefix: "Indcies_multifeature",
   fileFormat:"CSV",
});

I want to extract the values of NDVI and NDBI for multiple points in different featurecollection classes like Urban and Vegetation and export in different rows and columns. From the above code, the urban and vegetation are exported as 2 features(2 rows) and indices value of each point in the feature are exported together.

One Answer

Please, include a link to a working script and share all used assets. It makes it easier to help you.

You have an error in your script when clipping data. You probably want to call data.clip(aoi) instead of data.clipToCollection(aoi). data.clipToCollection() expects an ee.FeatureCollection argument.

You also need to provide a scale when reducing regions:

var img = SI.select(['NDBI','NDVI'])
 .reduceRegions({
   collection: feature,
   reducer: ee.Reducer.toList(),
   scale: 30
})

https://code.earthengine.google.com/85651439d2e7da0548d2c48092556200

Answered by Daniel Wiell on April 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP