ee.Image.arrayTranspose
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מבצעת טרנספוזיציה של שני מאפיינים של כל פיקסל במערך.
שימוש | החזרות |
---|
Image.arrayTranspose(axis1, axis2) | תמונה |
ארגומנט | סוג | פרטים |
---|
זה: input | תמונה | תמונת הקלט. |
axis1 | מספר שלם, ברירת מחדל: 0 | הציר הראשון להחלפה. |
axis2 | מספר שלם, ברירת מחדל: 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');
}
// 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]]
הגדרת Python
מידע על Python API ועל שימוש ב-geemap
לפיתוח אינטראקטיבי מופיע בדף
Python Environment.
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]]
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[null,null,["עדכון אחרון: 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```"]]