قدّمت Earth Engine
فئات حصص غير تجارية لحماية موارد الحوسبة المشتركة وضمان أداء موثوق للجميع. تستخدم المشاريع غير التجارية "فئة المجتمع" تلقائيًا، ولكن يمكنك تغيير فئة المشروع في أي وقت.
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
ee.ImageCollection.toArrayPerBand
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تدمج هذه الدالة صورًا متعددة في صورة صفيف واحدة.
| الاستخدام | المرتجعات |
|---|
ImageCollection.toArrayPerBand(axis, dropMasked) | صورة |
| الوسيطة | النوع | التفاصيل |
|---|
هذا: collection | ImageCollection | الصور المطلوب دمجها يتم إجراء عملية تسلسل منفصلة لكل نطاق، لذا يجب أن يكون لجميع الصور الأبعاد والشكل نفسهما لكل نطاق، باستثناء الطول على طول محور التسلسل. |
axis | عدد صحيح، القيمة التلقائية: 0 | المحور الذي سيتم الربط على طوله، ويجب أن تكون قيمته 0 على الأقل والحد الأدنى لأي بُعد في المجموعة على الأكثر. |
dropMasked | قيمة منطقية، القيمة التلقائية: false | إذا كانت القيمة خطأ (القيمة التلقائية)، تكون قيمة قناع البكسل الناتج هي الحد الأدنى لأقنعة البكسلات المدخلة. إذا تم إخفاء أي صورة في المجموعة ضِمن مربّع الإحاطة الخاص بالحساب بالكامل عند أحد وحدات البكسل، سيتم إخفاء وحدة البكسل الناتجة. نتيجةً لذلك، سيكون لكل مصفوفة بكسل ناتجة غير مخفية الحجم نفسه.
إذا كانت القيمة صحيحة، تكون قيمة قناع البكسل الناتج هي الحد الأقصى لقناع المدخلات. يتم تجاهل الصور التي تم إخفاء وحدات البكسل فيها بالكامل، ولا تساهم هذه الصور في توفير بيانات لمصفوفة الإخراج. وبالتالي، لن يكون حجم المصفوفات الناتجة متطابقًا بالضرورة لكل بكسل. |
أمثلة
أداة تعديل الرموز (JavaScript)
// A function to extract and print the array of a selected pixel.
function sampleArrayImage(arrImg) {
var point = ee.Geometry.Point([0, 0]);
return arrImg.sample(point, 1).first().get('b1');
}
// Define three single-band constant images with unified data types.
var img0 = ee.Image(0).byte().rename('b1');
var img1 = ee.Image(1).byte().rename('b1');
var img2 = ee.Image(2).byte().rename('b1');
// 1. Basic usage: concatenate fully valid images along axis 0.
var colSimple = ee.ImageCollection([img0, img1, img2]);
var arrayBasic = colSimple.toArrayPerBand();
print('Basic toArrayPerBand (pixel array):', sampleArrayImage(arrayBasic));
// Result: [0, 1, 2]
// 2. Masking behavior: introduce an image with a masked pixel.
// Update mask so img1 has no valid data at the sampled pixel.
var img1Masked = img1.updateMask(0);
var colMasked = ee.ImageCollection([img0, img1Masked, img2]);
// By default (dropMasked = false), if any input image is masked at a pixel,
// the output array is masked at that pixel. Since sampling a masked pixel
// returns no features, we inspect the output image's mask directly.
var arrayDefault = colMasked.toArrayPerBand();
print('Default masking behavior (pixel mask is 0):',
sampleArrayImage(arrayDefault.mask()));
// Result: 0
// With dropMasked = true, if any input image is masked at a specific pixel,
// its value is omitted from the output array at that pixel. As a result,
// array lengths can vary across different pixels.
var arrayDropped = colMasked.toArrayPerBand(0, true);
print('dropMasked=true (pixel array omits image-specific masked pixels):',
sampleArrayImage(arrayDropped));
// Result: [0, 2]
إعداد Python
راجِع صفحة
بيئة Python للحصول على معلومات حول واجهة برمجة التطبيقات Python واستخدام
geemap للتطوير التفاعلي.
import ee
import geemap.core as geemap
Colab (Python)
# A function to extract and print the array of a selected pixel.
def sample_array_image(arr_img):
point = ee.Geometry.Point([0, 0])
return arr_img.sample(point, 1).first().get('b1')
# Define three single-band constant images with unified data types.
img0 = ee.Image(0).byte().rename('b1')
img1 = ee.Image(1).byte().rename('b1')
img2 = ee.Image(2).byte().rename('b1')
# 1. Basic usage: concatenate fully valid images along axis 0.
col_simple = ee.ImageCollection([img0, img1, img2])
array_basic = col_simple.toArrayPerBand()
display('Basic toArrayPerBand (pixel array):', sample_array_image(array_basic))
# Result: [0, 1, 2]
# 2. Masking behavior: introduce an image with a masked pixel.
# Update mask so img1 has no valid data at the sampled pixel.
img1_masked = img1.updateMask(0)
col_masked = ee.ImageCollection([img0, img1_masked, img2])
# By default (dropMasked = False), if any input image is masked at a pixel,
# the output array is masked at that pixel. Since sampling a masked pixel
# returns no features, we inspect the output image's mask directly.
array_default = col_masked.toArrayPerBand()
display(
'Default masking behavior (pixel mask is 0):',
sample_array_image(array_default.mask()),
)
# Result: 0
# With dropMasked = true, if any input image is masked at a specific pixel,
# its value is omitted from the output array at that pixel. As a result,
# array lengths can vary across different pixels.
array_dropped = col_masked.toArrayPerBand(0, True)
display(
'dropMasked=True (pixel array omits image-specific masked pixels):',
sample_array_image(array_dropped),
)
# Result: [0, 2]
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2026-05-31 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2026-05-31 (حسب التوقيت العالمي المتفَّق عليه)"],[],[]]