إشعار : يجب
إثبات أهلية جميع المشاريع غير التجارية المسجّلة لاستخدام Earth Engine قبل
15 أبريل 2025 من أجل الحفاظ على إمكانية الوصول إلى Earth Engine.
إرسال ملاحظات
ee.ImageCollection.mode
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يقلّل مجموعة صور من خلال احتساب القيمة الأكثر شيوعًا في كل بكسل على مستوى حزمة جميع النطاقات المتطابقة. تتم مطابقة الفرق الموسيقية حسب الاسم.
الاستخدام المرتجعات ImageCollection. mode ()
صورة
الوسيطة النوع التفاصيل هذا: collection
ImageCollection مجموعة الصور التي سيتم تقليلها.
أمثلة
محرّر الرموز البرمجية (JavaScript)
// Sentinel-2 image collection for July 2021 intersecting a point of interest.
// Reflectance, cloud probability, and scene classification bands are selected.
var col = ee . ImageCollection ( 'COPERNICUS/S2_SR' )
. filterDate ( '2021-07-01' , '2021-08-01' )
. filterBounds ( ee . Geometry . Point ( - 122.373 , 37.448 ))
. select ( 'B.*|MSK_CLDPRB|SCL' );
// Visualization parameters for reflectance RGB.
var visRefl = {
bands : [ 'B11' , 'B8' , 'B3' ],
min : 0 ,
max : 4000
};
Map . setCenter ( - 122.373 , 37.448 , 9 );
Map . addLayer ( col , visRefl , 'Collection reference' , false );
// Reduce the collection to a single image using a variety of methods.
var mean = col . mean ();
Map . addLayer ( mean , visRefl , 'Mean (B11, B8, B3)' );
var median = col . median ();
Map . addLayer ( median , visRefl , 'Median (B11, B8, B3)' );
var min = col . min ();
Map . addLayer ( min , visRefl , 'Min (B11, B8, B3)' );
var max = col . max ();
Map . addLayer ( max , visRefl , 'Max (B11, B8, B3)' );
var sum = col . sum ();
Map . addLayer ( sum ,
{ bands : [ 'MSK_CLDPRB' ], min : 0 , max : 500 }, 'Sum (MSK_CLDPRB)' );
var product = col . product ();
Map . addLayer ( product ,
{ bands : [ 'MSK_CLDPRB' ], min : 0 , max : 1e10 }, 'Product (MSK_CLDPRB)' );
// ee.ImageCollection.mode returns the most common value. If multiple mode
// values occur, the minimum mode value is returned.
var mode = col . mode ();
Map . addLayer ( mode , { bands : [ 'SCL' ], min : 1 , max : 11 }, 'Mode (pixel class)' );
// ee.ImageCollection.count returns the frequency of valid observations. Here,
// image pixels are masked based on cloud probability to add valid observation
// variability to the collection. Note that pixels with no valid observations
// are masked out of the returned image.
var notCloudCol = col . map ( function ( img ) {
return img . updateMask ( img . select ( 'MSK_CLDPRB' ). lte ( 10 ));
});
var count = notCloudCol . count ();
Map . addLayer ( count , { min : 1 , max : 5 }, 'Count (not cloud observations)' );
// ee.ImageCollection.mosaic composites images according to their position in
// the collection (priority is last to first) and pixel mask status, where
// invalid (mask value 0) pixels are filled by preceding valid (mask value >0)
// pixels.
var mosaic = notCloudCol . mosaic ();
Map . addLayer ( mosaic , visRefl , 'Mosaic (B11, B8, B3)' );
إعداد Python
راجِع صفحة
بيئة Python للحصول على معلومات حول واجهة برمجة التطبيقات Python واستخدام
geemap
للتطوير التفاعلي.
import ee
import geemap.core as geemap
Colab (Python)
# Sentinel-2 image collection for July 2021 intersecting a point of interest.
# Reflectance, cloud probability, and scene classification bands are selected.
col = (
ee . ImageCollection ( 'COPERNICUS/S2_SR' )
. filterDate ( '2021-07-01' , '2021-08-01' )
. filterBounds ( ee . Geometry . Point ( - 122.373 , 37.448 ))
. select ( 'B.*|MSK_CLDPRB|SCL' )
)
# Visualization parameters for reflectance RGB.
vis_refl = { 'bands' : [ 'B11' , 'B8' , 'B3' ], 'min' : 0 , 'max' : 4000 }
m = geemap . Map ()
m . set_center ( - 122.373 , 37.448 , 9 )
m . add_layer ( col , vis_refl , 'Collection reference' , False )
# Reduce the collection to a single image using a variety of methods.
mean = col . mean ()
m . add_layer ( mean , vis_refl , 'Mean (B11, B8, B3)' )
median = col . median ()
m . add_layer ( median , vis_refl , 'Median (B11, B8, B3)' )
min = col . min ()
m . add_layer ( min , vis_refl , 'Min (B11, B8, B3)' )
max = col . max ()
m . add_layer ( max , vis_refl , 'Max (B11, B8, B3)' )
sum = col . sum ()
m . add_layer (
sum , { 'bands' : [ 'MSK_CLDPRB' ], 'min' : 0 , 'max' : 500 }, 'Sum (MSK_CLDPRB)'
)
product = col . product ()
m . add_layer (
product ,
{ 'bands' : [ 'MSK_CLDPRB' ], 'min' : 0 , 'max' : 1e10 },
'Product (MSK_CLDPRB)' ,
)
# ee.ImageCollection.mode returns the most common value. If multiple mode
# values occur, the minimum mode value is returned.
mode = col . mode ()
m . add_layer (
mode , { 'bands' : [ 'SCL' ], 'min' : 1 , 'max' : 11 }, 'Mode (pixel class)'
)
# ee.ImageCollection.count returns the frequency of valid observations. Here,
# image pixels are masked based on cloud probability to add valid observation
# variability to the collection. Note that pixels with no valid observations
# are masked out of the returned image.
not_cloud_col = col . map (
lambda img : img . updateMask ( img . select ( 'MSK_CLDPRB' ) . lte ( 10 ))
)
count = not_cloud_col . count ()
m . add_layer ( count , { 'min' : 1 , 'max' : 5 }, 'Count (not cloud observations)' )
# ee.ImageCollection.mosaic composites images according to their position in
# the collection (priority is last to first) and pixel mask status, where
# invalid (mask value 0) pixels are filled by preceding valid (mask value >0)
# pixels.
mosaic = not_cloud_col . mosaic ()
m . add_layer ( mosaic , vis_refl , 'Mosaic (B11, B8, B3)' )
m
إرسال ملاحظات
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0 . للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers . إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
هل تريد مشاركة ملاحظاتك معنا؟
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["`ImageCollection.mode()` reduces an image collection to a single image by calculating the most frequent pixel value for each band across the collection."],["Bands are matched by name during the reduction process."],["If multiple pixel values have the same highest frequency (multiple modes), the minimum mode value is selected for that pixel."],["The resulting image represents the most common values observed in the collection for each band."]]],["The content details the `mode()` function within an `ImageCollection`, which finds the most frequent pixel value across matching bands in a stack of images, returning a single `Image`. It demonstrates reducing an image collection using functions such as: `mean()`, `median()`, `min()`, `max()`, `sum()`, and `product()`. It also shows how to calculate a pixel frequency using `count()` and to mosaic together images with `mosaic()`. `mode` returns the lowest value if multiple values have the same frequency.\n"]]