আপনি একটি Image
বা FeatureCollection
প্রতিটি জোনে পরিসংখ্যান পেতে পারেন reducer.group()
ব্যবহার করে একটি রিডুসারের আউটপুটকে একটি নির্দিষ্ট ইনপুটের মান অনুসারে গ্রুপ করতে। উদাহরণস্বরূপ, প্রতিটি রাজ্যে মোট জনসংখ্যা এবং আবাসন ইউনিটের সংখ্যা গণনা করার জন্য, এই উদাহরণটি একটি আদমশুমারি ব্লক FeatureCollection
হ্রাসের আউটপুটকে নিম্নরূপ গ্রুপ করে:
কোড এডিটর (জাভাস্ক্রিপ্ট)
// Load a collection of US census blocks. var blocks = ee.FeatureCollection('TIGER/2010/Blocks'); // Compute sums of the specified properties, grouped by state code. var sums = blocks .filter(ee.Filter.and( ee.Filter.neq('pop10', null), ee.Filter.neq('housing10', null))) .reduceColumns({ selectors: ['pop10', 'housing10', 'statefp10'], reducer: ee.Reducer.sum().repeat(2).group({ groupField: 2, groupName: 'state-code', }) }); // Print the resultant Dictionary. print(sums);
import ee import geemap.core as geemap
Colab (পাইথন)
# Load a collection of US census blocks. blocks = ee.FeatureCollection('TIGER/2010/Blocks') # Compute sums of the specified properties, grouped by state code. sums = blocks.filter( ee.Filter.And( ee.Filter.neq('pop10', None), ee.Filter.neq('housing10', None) ) ).reduceColumns( selectors=['pop10', 'housing10', 'statefp10'], reducer=ee.Reducer.sum() .repeat(2) .group(groupField=2, groupName='state-code'), ) # Print the resultant Dictionary. display(sums)
groupField
আর্গুমেন্ট হল সিলেক্টর অ্যারের ইনপুটের সূচী যা গ্রুপ করার জন্য কোড ধারণ করে, groupName
আর্গুমেন্ট গ্রুপিং ভেরিয়েবলের মান সংরক্ষণ করার জন্য সম্পত্তির নাম নির্দিষ্ট করে। যেহেতু প্রতিটি ইনপুটের জন্য রিডুসার স্বয়ংক্রিয়ভাবে পুনরাবৃত্তি হয় না, repeat(2)
কল প্রয়োজন।
image.reduceRegions()
এর আউটপুট গ্রুপ করতে আপনি একটি গ্রুপিং ব্যান্ড নির্দিষ্ট করতে পারেন যা পূর্ণসংখ্যা পিক্সেল মান দ্বারা গোষ্ঠীকে সংজ্ঞায়িত করে। এই ধরণের গণনাকে কখনও কখনও "জোনাল পরিসংখ্যান" বলা হয় যেখানে অঞ্চলগুলিকে গ্রুপিং ব্যান্ড হিসাবে নির্দিষ্ট করা হয় এবং পরিসংখ্যানটি হ্রাসকারী দ্বারা নির্ধারিত হয়। নিম্নলিখিত উদাহরণে, মার্কিন যুক্তরাষ্ট্রে রাতের আলোর পরিবর্তনকে ল্যান্ড কভার বিভাগ দ্বারা গোষ্ঠীভুক্ত করা হয়েছে:
কোড এডিটর (জাভাস্ক্রিপ্ট)
// Load a region representing the United States var region = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017') .filter(ee.Filter.eq('country_na', 'United States')); // Load MODIS land cover categories in 2001. var landcover = ee.Image('MODIS/051/MCD12Q1/2001_01_01') // Select the IGBP classification band. .select('Land_Cover_Type_1'); // Load nightlights image inputs. var nl2001 = ee.Image('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS/F152001') .select('stable_lights'); var nl2012 = ee.Image('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS/F182012') .select('stable_lights'); // Compute the nightlights decadal difference, add land cover codes. var nlDiff = nl2012.subtract(nl2001).addBands(landcover); // Grouped a mean reducer: change of nightlights by land cover category. var means = nlDiff.reduceRegion({ reducer: ee.Reducer.mean().group({ groupField: 1, groupName: 'code', }), geometry: region.geometry(), scale: 1000, maxPixels: 1e8 }); // Print the resultant Dictionary. print(means);
import ee import geemap.core as geemap
Colab (পাইথন)
# Load a region representing the United States region = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017').filter( ee.Filter.eq('country_na', 'United States') ) # Load MODIS land cover categories in 2001. landcover = ee.Image('MODIS/051/MCD12Q1/2001_01_01').select( # Select the IGBP classification band. 'Land_Cover_Type_1' ) # Load nightlights image inputs. nl_2001 = ee.Image('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS/F152001').select( 'stable_lights' ) nl_2012 = ee.Image('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS/F182012').select( 'stable_lights' ) # Compute the nightlights decadal difference, add land cover codes. nl_diff = nl_2012.subtract(nl_2001).addBands(landcover) # Grouped a mean reducer: change of nightlights by land cover category. means = nl_diff.reduceRegion( reducer=ee.Reducer.mean().group(groupField=1, groupName='code'), geometry=region.geometry(), scale=1000, maxPixels=1e8, ) # Print the resultant Dictionary. display(means)
মনে রাখবেন যে এই উদাহরণে, groupField
হল ব্যান্ডের সূচী যেখানে জোন রয়েছে যার দ্বারা আউটপুটকে গ্রুপ করতে হবে। প্রথম ব্যান্ডটি সূচক 0, দ্বিতীয়টি সূচক 1 ইত্যাদি।