ee.Image.mask

이미지의 마스크를 가져오거나 설정합니다. 출력 이미지는 입력 이미지의 메타데이터와 설치 공간을 유지합니다. 마스크가 0에서 다른 값으로 변경되는 픽셀은 0 또는 픽셀 유형 범위 내에서 0에 가장 가까운 값으로 채워집니다.

사용반환 값
Image.mask(mask)이미지
인수유형세부정보
다음과 같은 경우: image이미지입력 이미지입니다.
mask이미지, 기본값: null마스크 이미지입니다. 지정된 경우 입력 이미지가 출력에 복사되지만 이 이미지의 값으로 마스크가 지정됩니다. 단일 밴드인 경우 입력 이미지의 모든 밴드에 사용됩니다. 지정하지 않으면 입력 이미지의 마스크에서 생성된 이미지를 반환합니다. 이 이미지는 [0:1] 범위로 조정됩니다(유효하지 않음 = 0, 유효함 = 1.0).

코드 편집기 (JavaScript)

// A Sentinel-2 surface reflectance image.
var img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');
var trueColorViz = {
  bands: ['B4', 'B3', 'B2'],
  min: 0,
  max: 2700,
  gamma: 1.3
};
print('Sentinel-2 image', img);
Map.setCenter(-122.36, 37.47, 10);
Map.addLayer(img, trueColorViz, 'Sentinel-2 image');

// Get masks for all image bands; each band has an independent mask.
// Valid pixels are value 1, invalid are 0.
var multiBandMaskImg = img.mask();
print('Multi-band mask image', multiBandMaskImg);
Map.addLayer(multiBandMaskImg, null, 'Multi-band mask image');

// Get the mask for a single image band.
var singleBandMaskImg = img.select('B1').mask();
print('Single-band mask image', singleBandMaskImg);
Map.addLayer(singleBandMaskImg, null, 'Single-band mask image');

Python 설정

Python API 및 geemap를 사용한 대화형 개발에 관한 자세한 내용은 Python 환경 페이지를 참고하세요.

import ee
import geemap.core as geemap

Colab (Python)

# A Sentinel-2 surface reflectance image.
img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')
true_color_viz = {
    'bands': ['B4', 'B3', 'B2'],
    'min': 0,
    'max': 2700,
    'gamma': 1.3,
}
display('Sentinel-2 image', img)
m = geemap.Map()
m.set_center(-122.36, 37.47, 10)
m.add_layer(img, true_color_viz, 'Sentinel-2 image')

# Get masks for all image bands each band has an independent mask.
# Valid pixels are value 1, invalid are 0.
multi_band_mask_img = img.mask()
display('Multi-band mask image', multi_band_mask_img)
m.add_layer(multi_band_mask_img, None, 'Multi-band mask image')

# Get the mask for a single image band.
single_band_mask_img = img.select('B1').mask()
display('Single-band mask image', single_band_mask_img)
m.add_layer(single_band_mask_img, None, 'Single-band mask image')
m