Annuncio: tutti i progetti non commerciali registrati per l'utilizzo di Earth Engine prima del
15 aprile 2025 devono
verificare l'idoneità non commerciale per mantenere l'accesso a Earth Engine.
ee.Image.arrayTranspose
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Trasponi due dimensioni di ogni pixel dell'array.
Utilizzo | Resi |
---|
Image.arrayTranspose(axis1, axis2) | Immagine |
Argomento | Tipo | Dettagli |
---|
questo: input | Immagine | Immagine di input. |
axis1 | Numero intero, valore predefinito: 0 | Il primo asse da scambiare. |
axis2 | Numero intero, valore predefinito: 1 | Il secondo asse da scambiare. |
Esempi
Editor di codice (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]]
Configurazione di Python
Consulta la pagina
Ambiente Python per informazioni sull'API Python e sull'utilizzo di
geemap
per lo sviluppo interattivo.
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]]
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-26 UTC.
[null,null,["Ultimo aggiornamento 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```"]]