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) | รูปภาพ |
| อาร์กิวเมนต์ | ประเภท | รายละเอียด |
|---|
this: collection | ImageCollection | รูปภาพที่จะเชื่อม ระบบจะเชื่อมแต่ละแบนด์แยกกัน ดังนั้นรูปภาพทั้งหมดต้องมีมิติและรูปร่างเหมือนกันต่อแบนด์ ยกเว้นความยาวตามแกนการเชื่อม |
axis | จำนวนเต็ม ค่าเริ่มต้นคือ 0 | แกนที่จะเชื่อม ต้องมีค่าอย่างน้อย 0 และไม่เกินมิติข้อมูลต่ำสุดของแบนด์ใดๆ ในคอลเล็กชัน |
dropMasked | บูลีน ค่าเริ่มต้นคือเท็จ | หากเป็นเท็จ (ค่าเริ่มต้น) ค่ามาสก์ของพิกเซลเอาต์พุตจะเป็นค่าต่ำสุดของมาสก์ของพิกเซลอินพุต หากรูปภาพใดๆ ในคอลเล็กชันภายในกรอบล้อมรอบการคำนวณถูกมาสก์ทั้งหมดที่พิกเซลหนึ่งๆ พิกเซลเอาต์พุตนั้นจะถูกมาสก์ ด้วยเหตุนี้ อาร์เรย์พิกเซลเอาต์พุตที่ไม่ได้มาสก์ทั้งหมดจะมีขนาดเท่ากัน
หากเป็นจริง ค่ามาสก์ของพิกเซลเอาต์พุตจะเป็นค่าสูงสุดของมาสก์ของอินพุต ระบบจะละเว้นรูปภาพที่ถูกมาสก์ทั้งหมดที่พิกเซลนั้น และรูปภาพดังกล่าวจะไม่ส่งข้อมูลไปยังอาร์เรย์เอาต์พุต ดังนั้น อาร์เรย์เอาต์พุตจึงอาจมีขนาดไม่เท่ากันสำหรับแต่ละพิกเซล |
ตัวอย่าง
ตัวแก้ไขโค้ด (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 API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้าสภาพแวดล้อม Python
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]
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2026-05-31 UTC
[null,null,["อัปเดตล่าสุด 2026-05-31 UTC"],[],[]]