ফিচার কালেকশন কলামের পরিসংখ্যান

FeatureCollection এ বৈশিষ্ট্যের বৈশিষ্ট্য কমাতে, featureCollection.reduceColumns() ব্যবহার করুন। নিম্নলিখিত খেলনা উদাহরণ বিবেচনা করুন:

// Make a toy FeatureCollection.
var aFeatureCollection = ee.FeatureCollection([
  ee.Feature(null, {foo: 1, weight: 1}),
  ee.Feature(null, {foo: 2, weight: 2}),
  ee.Feature(null, {foo: 3, weight: 3}),
]);

// Compute a weighted mean and display it.
print(aFeatureCollection.reduceColumns({
  reducer: ee.Reducer.mean(),
  selectors: ['foo'],
  weightSelectors: ['weight']
}));

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

import ee
import geemap.core as geemap
# Make a toy FeatureCollection.
a_feature_collection = ee.FeatureCollection([
    ee.Feature(None, {'foo': 1, 'weight': 1}),
    ee.Feature(None, {'foo': 2, 'weight': 2}),
    ee.Feature(None, {'foo': 3, 'weight': 3}),
])

# Compute a weighted mean and display it.
display(
    a_feature_collection.reduceColumns(
        reducer=ee.Reducer.mean(), selectors=['foo'], weightSelectors=['weight']
    )
)

উল্লেখ্য যে ইনপুটগুলি নির্দিষ্ট weight বৈশিষ্ট্য অনুযায়ী ওজন করা হয়। ফলাফল তাই:

mean: 2.333333333333333
    

আরও জটিল উদাহরণ হিসাবে, বৈশিষ্ট্য হিসাবে আদমশুমারি ডেটা সহ মার্কিন সেন্সাস ব্লকগুলির একটি FeatureCollection বিবেচনা করুন। আগ্রহের পরিবর্তনশীল হল মোট জনসংখ্যা এবং মোট আবাসন ইউনিট। আপনি reduceColumns() জন্য একটি যোগফল রিডুসার আর্গুমেন্ট সরবরাহ করে এবং ফলাফল মুদ্রণ করে তাদের যোগফল পেতে পারেন:

// Load US census data as a FeatureCollection.
var census = ee.FeatureCollection('TIGER/2010/Blocks');

// Filter the collection to include only Benton County, OR.
var benton = census.filter(
  ee.Filter.and(
    ee.Filter.eq('statefp10', '41'),
    ee.Filter.eq('countyfp10', '003')
  )
);

// Display Benton County census blocks.
Map.setCenter(-123.27, 44.57, 13);
Map.addLayer(benton);

// Compute sums of the specified properties.
var properties = ['pop10', 'housing10'];
var sums = benton
    .filter(ee.Filter.notNull(properties))
    .reduceColumns({
      reducer: ee.Reducer.sum().repeat(2),
      selectors: properties
    });

// Print the resultant Dictionary.
print(sums);

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

import ee
import geemap.core as geemap
# Load US census data as a FeatureCollection.
census = ee.FeatureCollection('TIGER/2010/Blocks')

# Filter the collection to include only Benton County, OR.
benton = census.filter(
    ee.Filter.And(
        ee.Filter.eq('statefp10', '41'), ee.Filter.eq('countyfp10', '003')
    )
)

# Display Benton County census blocks.
m = geemap.Map()
m.set_center(-123.27, 44.57, 13)
m.add_layer(benton)
display(m)

# Compute sums of the specified properties.
properties = ['pop10', 'housing10']
sums = benton.filter(ee.Filter.notNull(properties)).reduceColumns(
    reducer=ee.Reducer.sum().repeat(2), selectors=properties
)

# Print the resultant Dictionary.
display(sums)

আউটপুট হল একটি Dictionary নির্দিষ্ট রিডুসার অনুযায়ী সমষ্টিগত সম্পত্তির প্রতিনিধিত্ব করে:

sum: [85579,36245]
    

উল্লেখ্য যে উপরের উদাহরণটি notNull() ফিল্টার ব্যবহার করে শুধুমাত্র সংগ্রহে থাকা নির্বাচিত বৈশিষ্ট্যগুলির জন্য নন-নাল এন্ট্রি সহ বৈশিষ্ট্যগুলি অন্তর্ভুক্ত করে। অপ্রত্যাশিত অনুপস্থিত ডেটা ধরার জন্য নাল এন্ট্রিগুলি পরীক্ষা করা এবং শূন্য মানগুলি অন্তর্ভুক্ত করে এমন গণনার ফলে ত্রুটিগুলি এড়াতে এটি ভাল অনুশীলন।

এছাড়াও মনে রাখবেন যে imageCollection.reduce() বিপরীতে, যেখানে প্রতিটি ব্যান্ডের জন্য রিডুসারগুলি স্বয়ংক্রিয়ভাবে পুনরাবৃত্তি হয়, একটি FeatureCollection এ রিডুসারগুলি অবশ্যই repeat() ব্যবহার করে স্পষ্টভাবে পুনরাবৃত্তি করতে হবে। বিশেষত, মি ইনপুটগুলির জন্য রিডুসার m বার পুনরাবৃত্তি করুন। রিডুসার পুনরাবৃত্তি না করার ফলে নিম্নলিখিত ত্রুটিটি নিক্ষিপ্ত হতে পারে: