ee.Dictionary.toArray

Zwraca wartości liczbowe słownika jako tablicę. Jeśli nie podasz kluczy, wszystkie wartości zostaną zwrócone w naturalnej kolejności kluczy słownika. Domyślna wartość „axis” to 0.

WykorzystanieZwroty
Dictionary.toArray(keys, axis)Tablica
ArgumentTypSzczegóły
to: dictionarySłownik
keysLista, domyślna: null
axisLiczba całkowita, domyślnie: 0

Przykłady

Edytor kodu (JavaScript)

// A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
var dict = ee.Dictionary({
  B1: 182,
  B2: 219,
  B3: 443
});

print('Values for selected keys converted to ee.Array',
      dict.toArray(['B1', 'B2']));
print('Values for all keys converted to ee.Array',
      dict.toArray());

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)

# A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
dic = ee.Dictionary({
    'B1': 182,
    'B2': 219,
    'B3': 443
})

print('Values for selected keys converted to ee.Array:',
      dic.toArray(['B1', 'B2']).getInfo())
print('Values for all keys converted to ee.Array:',
      dic.toArray().getInfo())