Pengumuman: Semua project nonkomersial yang terdaftar untuk menggunakan Earth Engine sebelum
15 April 2025 harus
memverifikasi kelayakan nonkomersial untuk mempertahankan akses Earth Engine.
ee.Image.arrayTranspose
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Memindahkan dua dimensi setiap piksel array.
Penggunaan | Hasil |
---|
Image.arrayTranspose(axis1, axis2) | Gambar |
Argumen | Jenis | Detail |
---|
ini: input | Gambar | Gambar input. |
axis1 | Bilangan bulat, default: 0 | Sumbu pertama yang akan ditukar. |
axis2 | Bilangan bulat, default: 1 | Sumbu kedua yang akan ditukar. |
Contoh
Code Editor (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');
}
// Create a 2D array image.
var arrayImg2D = ee.Image([0, 1, 2, 3, 4, 5]).toArray().arrayReshape(
ee.Image([2, 3]).toArray(), 2);
print('2D 2x3 array image (pixel)', sampArrImg(arrayImg2D));
// [[0, 1, 2],
// [3, 4, 5]]
// Swap 0-axis and 1-axis. Input is a 2x3 array, output will be 3x2.
var transposed = arrayImg2D.arrayTranspose();
print('Transposed (3x2) array image (pixel)', sampArrImg(transposed));
// [[0, 3],
// [1, 4],
// [2, 5]]
Penyiapan Python
Lihat halaman
Lingkungan Python untuk mengetahui informasi tentang Python API dan penggunaan
geemap
untuk pengembangan interaktif.
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')
# Create a 2D array image.
array_img_2d = ee.Image([0, 1, 2, 3, 4, 5]).toArray().arrayReshape(
ee.Image([2, 3]).toArray(),
2
)
print('2D 2x3 array image (pixel):', samp_arr_img(array_img_2d).getInfo())
# [[0, 1, 2],
# [3, 4, 5]]
# Swap 0-axis and 1-axis. Input is a 2x3 array, output will be 3x2.
transposed = array_img_2d.arrayTranspose()
print('Transposed (3x2) array image (pixel):',
samp_arr_img(transposed).getInfo())
# [[0, 3],
# [1, 4],
# [2, 5]]
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-26 UTC.
[null,null,["Terakhir diperbarui pada 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eImage.arrayTranspose()\u003c/code\u003e transposes two dimensions of each array pixel within an image.\u003c/p\u003e\n"],["\u003cp\u003eBy default, it swaps the first (axis 0) and second (axis 1) dimensions of the array, effectively transposing a 2D array.\u003c/p\u003e\n"],["\u003cp\u003eUsers can specify which axes to swap using the \u003ccode\u003eaxis1\u003c/code\u003e and \u003ccode\u003eaxis2\u003c/code\u003e parameters.\u003c/p\u003e\n"],["\u003cp\u003eThis function is useful for manipulating the structure of array images, such as changing the orientation of a 2D array.\u003c/p\u003e\n"]]],[],null,["# ee.Image.arrayTranspose\n\nTransposes two dimensions of each array pixel.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------------------------------|---------|\n| Image.arrayTranspose`(`*axis1* `, `*axis2*`)` | Image |\n\n| Argument | Type | Details |\n|---------------|---------------------|----------------------|\n| this: `input` | Image | Input image. |\n| `axis1` | Integer, default: 0 | First axis to swap. |\n| `axis2` | Integer, default: 1 | Second axis to swap. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A function to print arrays for a selected pixel in the following examples.\nfunction sampArrImg(arrImg) {\n var point = ee.Geometry.Point([-121, 42]);\n return arrImg.sample(point, 500).first().get('array');\n}\n\n// Create a 2D array image.\nvar arrayImg2D = ee.Image([0, 1, 2, 3, 4, 5]).toArray().arrayReshape(\n ee.Image([2, 3]).toArray(), 2);\nprint('2D 2x3 array image (pixel)', sampArrImg(arrayImg2D));\n// [[0, 1, 2],\n// [3, 4, 5]]\n\n// Swap 0-axis and 1-axis. Input is a 2x3 array, output will be 3x2.\nvar transposed = arrayImg2D.arrayTranspose();\nprint('Transposed (3x2) array image (pixel)', sampArrImg(transposed));\n// [[0, 3],\n// [1, 4],\n// [2, 5]]\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# A function to print arrays for a selected pixel in the following examples.\ndef samp_arr_img(arr_img):\n point = ee.Geometry.Point([-121, 42])\n return arr_img.sample(point, 500).first().get('array')\n\n# Create a 2D array image.\narray_img_2d = ee.Image([0, 1, 2, 3, 4, 5]).toArray().arrayReshape(\n ee.Image([2, 3]).toArray(),\n 2\n)\nprint('2D 2x3 array image (pixel):', samp_arr_img(array_img_2d).getInfo())\n# [[0, 1, 2],\n# [3, 4, 5]]\n\n# Swap 0-axis and 1-axis. Input is a 2x3 array, output will be 3x2.\ntransposed = array_img_2d.arrayTranspose()\nprint('Transposed (3x2) array image (pixel):',\n samp_arr_img(transposed).getInfo())\n# [[0, 3],\n# [1, 4],\n# [2, 5]]\n```"]]