ee.FeatureCollection.reduceColumns

ইনপুট নির্ধারণ করতে প্রদত্ত নির্বাচক ব্যবহার করে সংগ্রহের প্রতিটি উপাদানে একটি রিডুসার প্রয়োগ করুন।

ফলাফলের একটি অভিধান প্রদান করে, আউটপুট নামের সাথে কী করা হয়।

ব্যবহার রিটার্নস
FeatureCollection. reduceColumns (reducer, selectors, weightSelectors ) অভিধান
যুক্তি টাইপ বিস্তারিত
এই: collection ফিচার কালেকশন সংগ্রহ ওভার সমষ্টি.
reducer হ্রাসকারী রিডুসার প্রয়োগ করতে হবে।
selectors তালিকা রিডুসারের প্রতিটি ইনপুটের জন্য একটি নির্বাচক।
weightSelectors তালিকা, ডিফল্ট: নাল হ্রাসকারীর প্রতিটি ওজনযুক্ত ইনপুটের জন্য একটি নির্বাচক৷

উদাহরণ

কোড এডিটর (জাভাস্ক্রিপ্ট)

// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
            .filter('country_lg == "Belgium"');

// Calculate mean of a single FeatureCollection property.
var propMean = fc.reduceColumns({
  reducer: ee.Reducer.mean(),
  selectors: ['gwh_estimt']
});
print('Mean of a single property', propMean);

// Calculate mean of multiple FeatureCollection properties.
var propsMean = fc.reduceColumns({
  reducer: ee.Reducer.mean().repeat(2),
  selectors: ['gwh_estimt', 'capacitymw']
});
print('Mean of multiple properties', propsMean);

// Calculate weighted mean of a single FeatureCollection property. Add a fuel
// source weight property to the FeatureCollection.
var fuelWeights = ee.Dictionary({
  Wind: 0.9,
  Gas: 0.2,
  Oil: 0.2,
  Coal: 0.1,
  Hydro: 0.7,
  Biomass: 0.5,
  Nuclear: 0.3
});
fc = fc.map(function(feature) {
  return feature.set('weight', fuelWeights.getNumber(feature.get('fuel1')));
});

var weightedMean = fc.reduceColumns({
  reducer: ee.Reducer.mean(),
  selectors: ['gwh_estimt'],
  weightSelectors: ['weight']
});
print('Weighted mean of a single property', weightedMean);

পাইথন সেটআপ

পাইথন এপিআই এবং ইন্টারেক্টিভ ডেভেলপমেন্টের জন্য geemap ব্যবহার করার জন্য পাইথন এনভায়রনমেন্ট পৃষ্ঠাটি দেখুন।

import ee
import geemap.core as geemap

Colab (পাইথন)

# FeatureCollection of power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
    'country_lg == "Belgium"')

# Calculate mean of a single FeatureCollection property.
prop_mean = fc.reduceColumns(**{
    'reducer': ee.Reducer.mean(),
    'selectors': ['gwh_estimt']
    })
print('Mean of a single property:', prop_mean.getInfo())

# Calculate mean of multiple FeatureCollection properties.
props_mean = fc.reduceColumns(**{
    'reducer': ee.Reducer.mean().repeat(2),
    'selectors': ['gwh_estimt', 'capacitymw']
    })
print('Mean of multiple properties:', props_mean.getInfo())


# Calculate weighted mean of a single FeatureCollection property. Add a fuel
# source weight property to the FeatureCollection.
def get_fuel(feature):
  return feature.set('weight', fuel_weights.getNumber(feature.get('fuel1')))

fuel_weights = ee.Dictionary({
    'Wind': 0.9,
    'Gas': 0.2,
    'Oil': 0.2,
    'Coal': 0.1,
    'Hydro': 0.7,
    'Biomass': 0.5,
    'Nuclear': 0.3
    })

fc = fc.map(get_fuel)

weighted_mean = fc.reduceColumns(**{
    'reducer': ee.Reducer.mean(),
    'selectors': ['gwh_estimt'],
    'weightSelectors': ['weight']
    })
print('Weighted mean of a single property:', weighted_mean.getInfo())