ee.Array.byte
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Rzutuje wartość wejściową na niepodpisaną 8-bitową liczbę całkowitą na poziomie poszczególnych elementów.
Wykorzystanie | Zwroty |
---|
Array.byte() | Tablica |
Argument | Typ | Szczegóły |
---|
to: input | Tablica | Tablica wejściowa. |
Przykłady
Edytor kodu (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 [[], []]
Konfiguracja Pythona
Informacje o interfejsie Python API i używaniu geemap
do interaktywnego programowania znajdziesz na stronie
Środowisko Python.
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()) # [[], []]
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
[null,null,["Ostatnia aktualizacja: 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```"]]