Earth Engine は、共有コンピューティングリソースを保護し、すべてのユーザーに信頼性の高いパフォーマンスを提供するために、
非商用割り当て階層を導入しています。非商用プロジェクトではデフォルトでコミュニティ
ティアが使用されますが、プロジェクトのティアはいつでも変更できます。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
ee.ImageCollection.toArrayPerBand
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
複数の画像を 1 つの配列画像に連結します。
| 用途 | 戻り値 |
|---|
ImageCollection.toArrayPerBand(axis, dropMasked) | 画像 |
| 引数 | タイプ | 詳細 |
|---|
この場合: collection | ImageCollection | 連結する画像。連結はバンドごとに行われるため、連結軸に沿った長さを除き、すべての画像はバンドごとに同じ次元と形状を持つ必要があります。 |
axis | 整数、デフォルト: 0 | 連結する軸。0 以上で、コレクション内の任意のバンドの最小ディメンション以下である必要があります。 |
dropMasked | ブール値、デフォルト: false | false(デフォルト)の場合、出力ピクセルのマスク値は入力ピクセルのマスクの最小値になります。計算境界ボックス内のコレクション内の画像がピクセルで完全にマスクされている場合、その出力ピクセルはマスクされます。その結果、マスクされていない出力ピクセル配列はすべて同じサイズになります。true の場合、出力ピクセルのマスク値は入力のマスクの最大値になります。そのピクセルで完全にマスクされた画像は無視され、出力配列にデータを提供しません。したがって、出力配列のサイズはピクセルごとに同じになるとは限りません。 |
例
コードエディタ(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。
[[["わかりやすい","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"]],["最終更新日 2026-05-31 UTC。"],[],[]]