ee.Image.remap

Mapeia valores de entrada para valores de saída, representados por duas listas paralelas. Os valores de entrada não incluídos na lista de entrada são definidos como "defaultValue", se fornecido, ou mascarados, caso contrário. As entradas que contêm valores de ponto flutuante às vezes podem não corresponder devido a erros de precisão de ponto flutuante.

UsoRetorna
Image.remap(from, to, defaultValue, bandName)Imagem
ArgumentoTipoDetalhes
isso: imageImagemA imagem a que o remapeamento é aplicado.
fromListaOs valores de origem (números ou ee.Array). Todos os valores nessa lista serão mapeados para o valor correspondente em "para".
toListaOs valores de destino (números ou ee.Array). Eles são usados para substituir os valores correspondentes em "from". Precisa ter o mesmo número de valores que "from".
defaultValueObjeto, padrão: nuloO valor padrão para substituir valores que não foram correspondidos por um valor em "from". Se não for especificado, os valores não correspondentes serão mascarados.
bandNameString, padrão: nullO nome da banda a ser remapeada. Se não for especificado, a primeira banda da imagem será usada.

Exemplos

Editor de código (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');

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)

# 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