Объявление : Все некоммерческие проекты, зарегистрированные для использования Earth Engine до
15 апреля 2025 года, должны
подтвердить некоммерческое право на сохранение доступа к Earth Engine.
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
Информацию об API Python и использовании geemap
для интерактивной разработки см. на странице «Среда 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()) # [[], []]
Если не указано иное, контент на этой странице предоставляется по лицензии Creative Commons "С указанием авторства 4.0", а примеры кода – по лицензии Apache 2.0. Подробнее об этом написано в правилах сайта. Java – это зарегистрированный товарный знак корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-07-24 UTC.
[null,null,["Последнее обновление: 2025-07-24 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```"]]