TransWikia.com

Calculate mean value from list features in Google Earth Engine

Geographic Information Systems Asked on January 1, 2021

I created a FeatureCollection containing 63 features with a different date, from one filter per ID.

In each of these 63 features, I created a new property named “matches” that contains a new list of features, which stores a value (called LANDSAT) for each of the 50 samples I disperse in my region.

enter image description here

Now, I would like to redeem the LANDSAT value of each list item and take the average, how would I do this?

 var collection = Collection .select(["NDVI_to_ajust"], ["LANDSAT"])

      var triplets = collection.map(
        function(image) {
        return image.reduceRegions({
          collection: samplesVegPrimaCinquenta, 
          reducer: ee.Reducer.mean().setOutputs(image.bandNames()), 
          scale: 30,
        }).map(
          function(feature) {

          return feature.set({
            'imageID': image.id(),
            'date': ee.Date(image.get('system:time_start')).format('Y-MM-dd')
          })
        });
      }).flatten();
      print(triplets,'triplets') 

    var coord = function(table,rowId, colId, rowProperty, colProperty){
      var rows = table.distinct(rowProperty);
      var joined = ee.Join.saveAll('matches').apply({
        primary: rows,
        secondary: table,
        condition: ee.Filter.equals({
          leftField: rowProperty, 
          rightField: rowProperty
        })
      });
    print(joined,'join by same ID/DATE')

Here’s the link code

One Answer

if you want to add the mean to each object of the collection you can do:

var colWithMeans=joined.map(function(ft){
   ft.set('requestedMean',ee.FeatureCollection(ee.List(ft.get('matches'))).aggregate_mean('LANDSAT'));
});

And if you want the global mean (mean of means) :

var globalMean= colWithMeans.aggregate_mean('requestedMean')

Answered by Mathieu Gravey on January 1, 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