Annuncio: tutti i progetti non commerciali registrati per l'utilizzo di Earth Engine prima del
15 aprile 2025 devono
verificare l'idoneità non commerciale per mantenere l'accesso a Earth Engine.
ee.Array.bitCount
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Calcola, in base agli elementi, il numero di bit impostati su 1 nella rappresentazione binaria in complemento a due a 64 bit dell'input.
Utilizzo | Resi |
---|
Array.bitCount() | Array |
Argomento | Tipo | Dettagli |
---|
questo: input | Array | L'array di input. |
Esempi
Editor di codice (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]
Configurazione di Python
Consulta la pagina
Ambiente Python per informazioni sull'API Python e sull'utilizzo di
geemap
per lo sviluppo interattivo.
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]
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-27 UTC.
[null,null,["Ultimo aggiornamento 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```"]]