Anúncio: todos os projetos não comerciais registrados para usar o Earth Engine antes de
15 de abril de 2025 precisam
verificar a qualificação não comercial para manter o acesso ao Earth Engine.
ee.Array.bitCount
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Calcula, elemento por elemento, o número de bits 1 na representação binária de complemento de dois de 64 bits da entrada.
Uso | Retorna |
---|
Array.bitCount() | Matriz |
Argumento | Tipo | Detalhes |
---|
isso: input | Matriz | A matriz de entrada. |
Exemplos
Editor de código (JavaScript)
print(ee.Array([], ee.PixelType.int8()).bitCount()); // []
print(ee.Array([0]).bitCount()); // [0]
print(ee.Array([1]).bitCount()); // [1]
print(ee.Array([2]).bitCount()); // [1]
print(ee.Array([3]).bitCount()); // [2]
print(ee.Array([0xFFFF]).bitCount()); // [16]
print(ee.Array([1, 2, 3]).bitCount()); // [1,1,2]
print(ee.Array([[0, 1], [6, 13]]).bitCount()); // [[0,1],[2,3]]
// https://en.wikipedia.org/wiki/Two's_complement signed values.
print(ee.Array([-1]).bitCount()); // [64]
print(ee.Array([-1], ee.PixelType.int8()).bitCount()); // [64]
print(ee.Array([-2]).bitCount()); // [63]
Configuração do Python
Consulte a página
Ambiente Python para informações sobre a API Python e como usar
geemap
para desenvolvimento interativo.
import ee
import geemap.core as geemap
Colab (Python)
display(ee.Array([], ee.PixelType.int8()).bitCount()) # []
display(ee.Array([0]).bitCount()) # [0]
display(ee.Array([1]).bitCount()) # [1]
display(ee.Array([2]).bitCount()) # [1]
display(ee.Array([3]).bitCount()) # [2]
display(ee.Array([0xFFFF]).bitCount()) # [16]
display(ee.Array([1, 2, 3]).bitCount()) # [1, 1, 2]
display(ee.Array([[0, 1], [6, 13]]).bitCount()) # [[0, 1], [2, 3]]
# https://en.wikipedia.org/wiki/Two's_complement signed values.
display(ee.Array([-1]).bitCount()) # [64]
display(ee.Array([-1], ee.PixelType.int8()).bitCount()) # [64]
display(ee.Array([-2]).bitCount()) # [63]
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2025-07-27 UTC.
[null,null,["Última atualização 2025-07-27 UTC."],[[["\u003cp\u003e\u003ccode\u003eArray.bitCount()\u003c/code\u003e calculates the number of 1s in the binary representation of each element in an array.\u003c/p\u003e\n"],["\u003cp\u003eIt operates on 64-bit two's complement binary representation, supporting both positive and negative integers.\u003c/p\u003e\n"],["\u003cp\u003eThe function returns an array with the same dimensions as the input, where each element represents the bit count of the corresponding input element.\u003c/p\u003e\n"],["\u003cp\u003eThis method works for arrays of various data types, including int8, int16, int32, and int64.\u003c/p\u003e\n"],["\u003cp\u003eIt handles empty arrays, single-element arrays, multi-dimensional arrays, and arrays with both positive and negative numbers.\u003c/p\u003e\n"]]],["The `bitCount()` function calculates the number of one-bits in the 64-bit two's complement binary representation of each element in an input array. It operates element-wise and returns a new array with the same shape as the input. The input array can contain positive or negative integers, and the output array provides the one-bit count for each corresponding element. For example, `ee.Array([1, 2, 3]).bitCount()` returns `[1, 1, 2]`.\n"],null,["# ee.Array.bitCount\n\nOn an element-wise basis, calculates the number of one-bits in the 64-bit two's complement binary representation of the input.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|--------------------|---------|\n| Array.bitCount`()` | 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\nprint(ee.Array([], ee.PixelType.int8()).bitCount()); // []\n\nprint(ee.Array([0]).bitCount()); // [0]\nprint(ee.Array([1]).bitCount()); // [1]\nprint(ee.Array([2]).bitCount()); // [1]\nprint(ee.Array([3]).bitCount()); // [2]\nprint(ee.Array([0xFFFF]).bitCount()); // [16]\nprint(ee.Array([1, 2, 3]).bitCount()); // [1,1,2]\n\nprint(ee.Array([[0, 1], [6, 13]]).bitCount()); // [[0,1],[2,3]]\n\n// https://en.wikipedia.org/wiki/Two's_complement signed values.\nprint(ee.Array([-1]).bitCount()); // [64]\nprint(ee.Array([-1], ee.PixelType.int8()).bitCount()); // [64]\nprint(ee.Array([-2]).bitCount()); // [63]\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\ndisplay(ee.Array([], ee.PixelType.int8()).bitCount()) # []\n\ndisplay(ee.Array([0]).bitCount()) # [0]\ndisplay(ee.Array([1]).bitCount()) # [1]\ndisplay(ee.Array([2]).bitCount()) # [1]\ndisplay(ee.Array([3]).bitCount()) # [2]\ndisplay(ee.Array([0xFFFF]).bitCount()) # [16]\ndisplay(ee.Array([1, 2, 3]).bitCount()) # [1, 1, 2]\n\ndisplay(ee.Array([[0, 1], [6, 13]]).bitCount()) # [[0, 1], [2, 3]]\n\n# https://en.wikipedia.org/wiki/Two's_complement signed values.\ndisplay(ee.Array([-1]).bitCount()) # [64]\ndisplay(ee.Array([-1], ee.PixelType.int8()).bitCount()) # [64]\ndisplay(ee.Array([-2]).bitCount()) # [63]\n```"]]