ee.Array.byte
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מבצע המרה של ערך הקלט למספר שלם לא מסומן של 8 ביט, על בסיס כל רכיב בנפרד.
שימוש | החזרות |
---|
Array.byte() | מערך |
ארגומנט | סוג | פרטים |
---|
זה: input | מערך | מערך הקלט. |
דוגמאות
עורך הקוד (JavaScript)
// Clamps below at 0.
print(ee.Array([-1]).byte()); // [0]
print(ee.Array([255]).byte()); // [255]
// Clamps above at 255.
print(ee.Array([256]).byte()); // [255]
// Rounds. [0,0,1,127,255,255]
print(ee.Array([-0.1, 0.1, 0.5, 127.1, 255.1, 255.9]).byte());
// Requires an explicit PixelType if no data.
print(ee.Array([[], []], ee.PixelType.float()).byte()); // Empty [[], []]
הגדרת Python
מידע על Python API ועל שימוש ב-geemap
לפיתוח אינטראקטיבי מופיע בדף
Python Environment.
import ee
import geemap.core as geemap
Colab (Python)
# Clamps below at 0.
display(ee.Array([-1]).byte()) # [0]
display(ee.Array([255]).byte()) # [255]
# Clamps above at 255.
display(ee.Array([256]).byte()) # [255]
# Rounds. [0, 0, 1, 127, 255, 255]
display(ee.Array([-0.1, 0.1, 0.5, 127.1, 255.1, 255.9]).byte())
# Requires an explicit PixelType if no data.
display(ee.Array([[], []], ee.PixelType.float()).byte()) # [[], []]
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון 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\u003eArray.byte()\u003c/code\u003e casts the input array values to unsigned 8-bit integers, element-wise.\u003c/p\u003e\n"],["\u003cp\u003eValues less than 0 are clamped to 0, and values greater than 255 are clamped to 255.\u003c/p\u003e\n"],["\u003cp\u003eInput values are rounded to the nearest integer before casting.\u003c/p\u003e\n"],["\u003cp\u003eWhen the input array has no data, an explicit \u003ccode\u003ePixelType\u003c/code\u003e is required.\u003c/p\u003e\n"]]],["The `Array.byte()` method casts array elements to unsigned 8-bit integers. Input values below 0 are clamped to 0, while values above 255 are clamped to 255. Decimal values are rounded to the nearest integer. If the input array is empty, an explicit `PixelType` is needed. This method returns a new array with the transformed elements. It can be used in both JavaScript and Python.\n"],null,["# ee.Array.byte\n\nOn an element-wise basis, casts the input value to an unsigned 8-bit integer.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|----------------|---------|\n| Array.byte`()` | Array |\n\n| Argument | Type | Details |\n|---------------|-------|------------------|\n| this: `input` | Array | The input array. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Clamps below at 0.\nprint(ee.Array([-1]).byte()); // [0]\nprint(ee.Array([255]).byte()); // [255]\n// Clamps above at 255.\nprint(ee.Array([256]).byte()); // [255]\n\n// Rounds. [0,0,1,127,255,255]\nprint(ee.Array([-0.1, 0.1, 0.5, 127.1, 255.1, 255.9]).byte());\n\n// Requires an explicit PixelType if no data.\nprint(ee.Array([[], []], ee.PixelType.float()).byte()); // Empty [[], []]\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# Clamps below at 0.\ndisplay(ee.Array([-1]).byte()) # [0]\ndisplay(ee.Array([255]).byte()) # [255]\n# Clamps above at 255.\ndisplay(ee.Array([256]).byte()) # [255]\n\n# Rounds. [0, 0, 1, 127, 255, 255]\ndisplay(ee.Array([-0.1, 0.1, 0.5, 127.1, 255.1, 255.9]).byte())\n\n# Requires an explicit PixelType if no data.\ndisplay(ee.Array([[], []], ee.PixelType.float()).byte()) # [[], []]\n```"]]