ee.Array.bitCount

Tính số lượng bit 1 trong biểu diễn nhị phân bù hai 64 bit của đầu vào theo từng phần tử.

Cách sử dụngGiá trị trả về
Array.bitCount()Mảng
Đối sốLoạiThông tin chi tiết
this: inputMảngMảng đầu vào.

Ví dụ

Trình soạn thảo mã (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]

Thiết lập Python

Hãy xem trang Môi trường Python để biết thông tin về API Python và cách sử dụng geemap cho quá trình phát triển tương tác.

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]