Franklin Januário
Franklin Januário

Reputation: 125

Extract Index vegetation by points over collection in GEE

How I can extract index vegetation points over collections by adapting this beautiful code by @Rodrigo E. Principe:

Extract pixel values by points and convert to a table in Google Earth Engine

I try extract all values mas GEE is crashing, so only NDVI or EVI can works fine.

Upvotes: 1

Views: 376

Answers (1)

Franklin Januário
Franklin Januário

Reputation: 125

I did it with this tutorial https://developers.google.com/earth-engine/tutorial_api_06

 // Dataset do sensor LS8
var dataset = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
                  .filterDate('2018-04-01', '2019-03-31')
                  .select('B5', 'B4')
                  .filterBounds(aoi6010)
                  .filter(ee.Filter.lt('CLOUD_COVER', 20));


var addNDVI = function(image) {
  var ndvi = image.normalizedDifference(['B5', 'B4']).rename('NDVI');
  return image.addBands(ndvi);
};

var withNDVI = dataset.map(addNDVI);

print(withNDVI);

// Empty Collection to fill
var ft = ee.FeatureCollection(ee.List([]))

var fill = function(img, ini) {
  // type cast
  var inift = ee.FeatureCollection(ini)

  // gets the values for the points in the current img
  var ft2 = img.reduceRegions(p601018, ee.Reducer.first(),30)

  // gets the date of the img
  var date = img.date().format()

  // writes the date in each feature
  var ft3 = ft2.map(function(f){return f.set("date", date)})

  // merges the FeatureCollections
  return inift.merge(ft3)
}

// Iterates over the ImageCollection
var newft = ee.FeatureCollection(withNDVI.iterate(fill, ft))

Upvotes: 1

Related Questions