ee.Image.remap

두 개의 병렬 목록으로 표시되는 입력 값에서 출력 값으로의 매핑입니다. 입력 목록에 포함되지 않은 입력 값은 defaultValue가 제공된 경우 defaultValue로 설정되고 그렇지 않은 경우 마스크 처리됩니다. 부동 소수점 값을 포함하는 입력은 부동 소수점 정밀도 오류로 인해 일치하지 않을 수 있습니다.

사용반환 값
Image.remap(from, to, defaultValue, bandName)이미지
인수유형세부정보
다음과 같은 경우: image이미지리매핑이 적용되는 이미지입니다.
from목록소스 값 (숫자 또는 ee.Array)입니다. 이 목록의 모든 값은 'to'의 해당 값에 매핑됩니다.
to목록대상 값 (숫자 또는 ee.Array)입니다. 이러한 값은 'from'의 해당 값을 대체하는 데 사용됩니다. 'from'과 동일한 수의 값이 있어야 합니다.
defaultValue객체, 기본값: null'from'의 값과 일치하지 않는 값을 대체하는 기본값입니다. 지정하지 않으면 일치하지 않는 값이 마스크 처리됩니다.
bandName문자열, 기본값: null리매핑할 밴드의 이름입니다. 지정하지 않으면 이미지의 첫 번째 밴드가 사용됩니다.

코드 편집기 (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');

Python 설정

Python API 및 geemap를 사용한 대화형 개발에 관한 자세한 내용은 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