Ogłoszenie: wszystkie projekty niekomercyjne zarejestrowane do korzystania z Earth Engine przed
15 kwietnia 2025 r. muszą
potwierdzić spełnianie warunków użycia niekomercyjnego, aby zachować dostęp. Jeśli nie przejdziesz weryfikacji do 26 września 2025 r., Twój dostęp może zostać wstrzymany.
ee.Image.remap
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Mapuje wartości wejściowe na wartości wyjściowe, które są reprezentowane przez 2 równoległe listy. Wszystkie wartości wejściowe, które nie są uwzględnione na liście wejściowej, są ustawiane na wartość domyślną, jeśli jest podana, lub maskowane, jeśli nie jest. Pamiętaj, że dane wejściowe zawierające wartości zmiennoprzecinkowe mogą czasami nie pasować z powodu błędów precyzji zmiennoprzecinkowej.
| Wykorzystanie | Zwroty |
|---|
Image.remap(from, to, defaultValue, bandName) | Obraz |
| Argument | Typ | Szczegóły |
|---|
to: image | Obraz | Obraz, do którego zastosowano ponowne mapowanie. |
from | Lista | Wartości źródłowe (liczby lub ee.Array). Wszystkie wartości na tej liście zostaną zmapowane na odpowiednią wartość w polu „to”. |
to | Lista | Wartości docelowe (liczby lub ee.Array). Służą one do zastępowania odpowiednich wartości w parametrze „from”. Musi zawierać tyle samo wartości co pole „from”. |
defaultValue | Obiekt, domyślnie: null | Wartość domyślna, która zastępuje wartości, które nie zostały dopasowane do wartości w parametrze „from”. Jeśli nie zostanie określona, niepasujące wartości są maskowane. |
bandName | Ciąg tekstowy, domyślnie: null | Nazwa pasma do ponownego mapowania. Jeśli nie zostanie określony, użyty zostanie pierwszy pasmo na obrazie. |
Przykłady
Edytor kodu (JavaScript)
// A land cover image.
var img = ee.Image('ESA/WorldCover/v100/2020');
// A list of pixel values to replace.
var fromList = [10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 100];
// A corresponding list of replacement values (10 becomes 1, 20 becomes 2, etc).
var toList = [ 1, 2, 2, 2, 3, 2, 4, 5, 6, 6, 2];
// Replace pixel values in the image. If the image is multi-band, only the
// remapped band will be returned. The returned band name is "remapped".
// Input image properties are retained in the output image.
var imgRemap = img.remap({
from: fromList,
to: toList,
defaultValue: 0,
bandName: 'Map'
});
// Display the original and remapped images. Note that similar land cover
// classes in the original image are grouped into aggregate classes by
// from → to value mapping.
Map.addLayer(img, null, 'Original image');
Map.addLayer(imgRemap, {
min: 1, max: 6,
palette:'darkgreen, lightgreen, red, white, blue, lightblue'
}, 'Remapped image');
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 land cover image.
img = ee.Image('ESA/WorldCover/v100/2020')
# A list of pixel values to replace.
from_list = [10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 100]
# A corresponding list of replacement values (10 becomes 1, 20 becomes 2, etc).
to_list = [1, 2, 2, 2, 3, 2, 4, 5, 6, 6, 2]
# Replace pixel values in the image. If the image is multi-band, only the
# remapped band will be returned. The returned band name is "remapped".
# Input image properties are retained in the output image.
img_remap = img.remap(from_list, to_list, defaultValue=0, bandName='Map')
# Display the original and remapped images. Note that similar land cover
# classes in the original image are grouped into aggregate classes by
# from → to value mapping.
m = geemap.Map()
m.add_layer(img, None, 'Original image')
m.add_layer(
img_remap,
{
'min': 1,
'max': 6,
'palette': [
'darkgreen',
'lightgreen',
'red',
'white',
'blue',
'lightblue',
],
},
'Remapped image',
)
m
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
[null,null,["Ostatnia aktualizacja: 2025-07-26 UTC."],[],["The `Image.remap` function replaces pixel values in an image based on two parallel lists: `from` and `to`. Values in `from` are mapped to corresponding values in `to`. Unmatched values are set to `defaultValue` if provided, otherwise they are masked. The function allows users to specify a `bandName`. It is designed to aggregate similar classes by mapping original values to new values, the remapped band name is \"remapped\".\n"]]