お知らせ :
2025 年 4 月 15 日 より前に Earth Engine の使用を登録したすべての非商用プロジェクトは、アクセスを維持するために
非商用目的での利用資格を確認 する必要があります。2025 年 9 月 26 日までに確認が完了していない場合、アクセスが保留されることがあります。
フィードバックを送信
ee.Image.toArray
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
各バンドのピクセルをピクセルごとに 1 つの配列に連結します。入力バンドがマスクされている場合、結果はマスクされます。
用途 戻り値 Image. toArray (axis )
画像
引数 タイプ 詳細 これ: image
画像 バンドの画像をピクセル単位の配列に変換します。バンドには、スカラー ピクセルまたは次元が等しい配列ピクセルが必要です。 axis
整数、デフォルト: 0 連結する軸。0 以上で、入力のディメンション以下である必要があります。軸が入力のディメンションと等しい場合、結果のディメンションは入力のディメンションより 1 つ多くなります。
例
コードエディタ(JavaScript)
// A function to print arrays for a selected pixel in the following examples.
function sampArrImg ( arrImg ) {
var point = ee . Geometry . Point ([ - 121 , 42 ]);
return arrImg . sample ( point , 500 ). first (). get ( 'array' );
}
// A 3-band image of constants.
var img = ee . Image ([ 0 , 1 , 2 ]);
print ( '3-band image' , img );
// Convert the 3-band image to an array image. The resulting array image has a
// single band named "array". The "array" band stores the per-pixel band values
// from the input ee.Image as a 1D array.
var arrayImg1D = img . toArray ();
print ( '1D array image' , arrayImg1D );
// Sample a single pixel to see its 1D array using the `sampArrImg` function
// defined above. Similar arrays are present for all pixels in a given array
// image; looking at just one helps conceptualize the structure.
print ( '1D array image (pixel)' , sampArrImg ( arrayImg1D ));
// [0, 1, 2]
// Array images can be displayed to the Code Editor map and queried with the
// inspector tool. Per-pixel, the first element in the array is shown.
// Single-band grayscale is used to represent the data. Style parameters `min`
// and `max` are valid. Styling the layer with the Code Editor's layer
// visualization tool is invalid.
Map . addLayer ( arrayImg1D , { min : 0 , max : 2 }, 'Image array' );
// Create a 2D array image by concatenating the values in a 1D array image
// along the 1-axis using `toArray(1)`. For a 3D array, apply `toArray(2)` to
// the result.
var arrayImg2D = arrayImg1D . toArray ( 1 );
print ( '2D array image (pixel)' , sampArrImg ( arrayImg2D ));
// [[0],
// [1],
// [2]]
Python の設定
Python API とインタラクティブな開発での geemap
の使用については、
Python 環境 のページをご覧ください。
import ee
import geemap.core as geemap
Colab(Python)
# A function to print arrays for a selected pixel in the following examples.
def samp_arr_img ( arr_img ):
point = ee . Geometry . Point ([ - 121 , 42 ])
return arr_img . sample ( point , 500 ) . first () . get ( 'array' )
# A 3-band image of constants.
img = ee . Image ([ 0 , 1 , 2 ])
display ( '3-band image' , img )
# Convert the 3-band image to an array image. The resulting array image has a
# single band named "array". The "array" band stores the per-pixel band values
# from the input ee.Image as a 1D array.
array_img_1_d = img . toArray ()
display ( '1D array image' , array_img_1_d )
# Sample a single pixel to see its 1D array using the `samp_arr_img` function
# defined above. Similar arrays are present for all pixels in a given array
# image looking at just one helps conceptualize the structure.
display ( '1D array image (pixel)' , samp_arr_img ( array_img_1_d ))
# [0, 1, 2]
# Array images can be displayed to the Code Editor map and queried with the
# inspector tool. Per-pixel, the first element in the array is shown.
# Single-band grayscale is used to represent the data. Style parameters `min`
# and `max` are valid. Styling the layer with the Code Editor's layer
# visualization tool is invalid.
m = geemap . Map ()
m . add_layer ( array_img_1_d , { 'min' : 0 , 'max' : 2 }, 'Image array' )
display ( m )
# Create a 2D array image by concatenating the values in a 1D array image
# along the 1-axis using `toArray(1)`. For a 3D array, apply `toArray(2)` to
# the result.
array_img_2_d = array_img_1_d . toArray ( 1 )
display ( '2D array image (pixel)' , samp_arr_img ( array_img_2_d ))
# [[0],
# [1],
# [2]]
フィードバックを送信
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンス により使用許諾されます。コードサンプルは Apache 2.0 ライセンス により使用許諾されます。詳しくは、Google Developers サイトのポリシー をご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-26 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"]],["最終更新日 2025-07-26 UTC。"],[],["The `toArray()` method concatenates pixel values from an image's bands into a single array per pixel. It takes an optional `axis` argument to specify the concatenation direction; the default is 0. The method converts the multi-band image to an array image, resulting in a single \"array\" band. If any input band has masked pixels, the resulting array will also be masked. You can use `toArray(1)` to create 2D array image or `toArray(2)` to create 3D array.\n"]]