Anúncio: todos os projetos não comerciais registrados para usar o Earth Engine antes de
15 de abril de 2025 precisam
verificar a qualificação não comercial para manter o acesso ao Earth Engine.
ee.Image.remap
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
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.
Uso | Retorna |
---|
Image.remap(from, to, defaultValue, bandName) | Imagem |
Argumento | Tipo | Detalhes |
---|
isso: image | Imagem | A imagem a que o remapeamento é aplicado. |
from | Lista | Os valores de origem (números ou ee.Array). Todos os valores nessa lista serão mapeados para o valor correspondente em "para". |
to | Lista | Os 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". |
defaultValue | Objeto, padrão: nulo | O 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. |
bandName | String, padrão: null | O 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
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2025-07-26 UTC.
[null,null,["Última atualização 2025-07-26 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eImage.remap()\u003c/code\u003e function transforms image pixel values by mapping values from an input list (\u003ccode\u003efrom\u003c/code\u003e) to a corresponding output list (\u003ccode\u003eto\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eUnmatched input values are either assigned a specified \u003ccode\u003edefaultValue\u003c/code\u003e or masked if no default is provided.\u003c/p\u003e\n"],["\u003cp\u003eRemapping can be applied to a specific band using the \u003ccode\u003ebandName\u003c/code\u003e parameter, otherwise, the first band is used by default.\u003c/p\u003e\n"],["\u003cp\u003ePotential floating-point precision errors might affect the matching of input values.\u003c/p\u003e\n"]]],["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"],null,["# ee.Image.remap\n\nMaps from input values to output values, represented by two parallel lists. Any input values not included in the input list are either set to defaultValue if it is given or masked if it isn't. Note that inputs containing floating point values might sometimes fail to match due to floating point precision errors.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|----------------------------------------------------------|---------|\n| Image.remap`(from, to, `*defaultValue* `, `*bandName*`)` | Image |\n\n| Argument | Type | Details |\n|----------------|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `image` | Image | The image to which the remapping is applied. |\n| `from` | List | The source values (numbers or ee.Array). All values in this list will be mapped to the corresponding value in 'to'. |\n| `to` | List | The destination values (numbers or ee.Array). These are used to replace the corresponding values in 'from'. Must have the same number of values as 'from'. |\n| `defaultValue` | Object, default: null | The default value to replace values that weren't matched by a value in 'from'. If not specified, unmatched values are masked out. |\n| `bandName` | String, default: null | The name of the band to remap. If not specified, the first band in the image is used. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A land cover image.\nvar img = ee.Image('ESA/WorldCover/v100/2020');\n\n// A list of pixel values to replace.\nvar fromList = [10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 100];\n\n// A corresponding list of replacement values (10 becomes 1, 20 becomes 2, etc).\nvar toList = [ 1, 2, 2, 2, 3, 2, 4, 5, 6, 6, 2];\n\n// Replace pixel values in the image. If the image is multi-band, only the\n// remapped band will be returned. The returned band name is \"remapped\".\n// Input image properties are retained in the output image.\nvar imgRemap = img.remap({\n from: fromList,\n to: toList,\n defaultValue: 0,\n bandName: 'Map'\n});\n\n// Display the original and remapped images. Note that similar land cover\n// classes in the original image are grouped into aggregate classes by\n// from → to value mapping.\nMap.addLayer(img, null, 'Original image');\nMap.addLayer(imgRemap, {\n min: 1, max: 6,\n palette:'darkgreen, lightgreen, red, white, blue, lightblue'\n }, 'Remapped image');\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\n# A land cover image.\nimg = ee.Image('ESA/WorldCover/v100/2020')\n\n# A list of pixel values to replace.\nfrom_list = [10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 100]\n\n# A corresponding list of replacement values (10 becomes 1, 20 becomes 2, etc).\nto_list = [1, 2, 2, 2, 3, 2, 4, 5, 6, 6, 2]\n\n# Replace pixel values in the image. If the image is multi-band, only the\n# remapped band will be returned. The returned band name is \"remapped\".\n# Input image properties are retained in the output image.\nimg_remap = img.remap(from_list, to_list, defaultValue=0, bandName='Map')\n\n# Display the original and remapped images. Note that similar land cover\n# classes in the original image are grouped into aggregate classes by\n# from → to value mapping.\nm = geemap.Map()\nm.add_layer(img, None, 'Original image')\nm.add_layer(\n img_remap,\n {\n 'min': 1,\n 'max': 6,\n 'palette': [\n 'darkgreen',\n 'lightgreen',\n 'red',\n 'white',\n 'blue',\n 'lightblue',\n ],\n },\n 'Remapped image',\n)\nm\n```"]]