공지사항 :
2025년 4월 15일 전에 Earth Engine 사용을 위해 등록된 모든 비상업용 프로젝트는 액세스 권한을 유지하기 위해
비상업용 자격 요건을 인증 해야 합니다. 2025년 9월 26일까지 인증하지 않으면 액세스가 보류될 수 있습니다.
의견 보내기
ee.Image.updateMask
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
기존 마스크가 0이 아닌 모든 위치에서 이미지의 마스크를 업데이트합니다. 출력 이미지는 입력 이미지의 메타데이터와 설치 공간을 유지합니다.
사용 반환 값 Image. updateMask (mask)
이미지
인수 유형 세부정보 다음과 같은 경우: image
이미지 입력 이미지입니다. mask
이미지 이미지의 새 마스크입니다. [0, 1] 범위의 부동 소수점 값입니다(유효하지 않음 = 0, 유효함 = 1). 이 이미지가 단일 밴드를 갖는 경우 입력 이미지의 모든 밴드에 사용됩니다. 그렇지 않으면 입력 이미지와 동일한 수의 밴드를 가져야 합니다.
예
코드 편집기 (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' );
// Create a Boolean land mask from the SWIR1 band; water is value 0, land is 1.
var landMask = img . select ( 'B11' ). gt ( 100 );
print ( 'Land mask' , landMask );
Map . addLayer ( landMask , { palette : [ 'blue' , 'lightgreen' ]}, 'Land mask' );
// Apply the single-band land mask to all image bands; pixel values equal to 0
// in the mask become invalid in the image.
var imgMasked = img . updateMask ( landMask );
print ( 'Image, land only' , imgMasked );
Map . addLayer ( imgMasked , trueColorViz , 'Image, land only' );
// Masks are band-specific. Here, a multi-band mask image is used to update
// corresponding input image band masks.
var imgBandSubset = img . select ([ 'B4' , 'B3' , 'B2' ]);
var bandSpecificMasks = imgBandSubset . gt ( 200 );
var imgBandSubsetMasked = imgBandSubset . updateMask ( bandSpecificMasks );
print ( 'Multi-band mask image' , bandSpecificMasks );
print ( 'Image, variable band masks' , imgBandSubsetMasked );
Map . addLayer ( bandSpecificMasks , null , 'Multi-band mask image' );
Map . addLayer ( imgBandSubsetMasked , trueColorViz , 'Image, variable band masks' );
// Note that there is only a single alpha channel for visualization, so when
// the ee.Image is rendered as an RGB image or map tiles, a masked pixel in any
// band will result in transparency for all bands.
// Floating point mask values between 0 and 1 will be used to define opacity
// in visualization via Map.addLayer and ee.Image.visualize.
var landMaskFloat = landMask . add ( 0.65 );
var imgMaskedFloat = img . updateMask ( landMaskFloat );
print ( 'Image, partially transparent' , imgMaskedFloat );
Map . addLayer ( imgMaskedFloat , trueColorViz , 'Image, partially transparent' );
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' )
# Create a Boolean land mask from the SWIR1 band water is value 0, land is 1.
land_mask = img . select ( 'B11' ) . gt ( 100 )
display ( 'Land mask' , land_mask )
m . add_layer ( land_mask , { 'palette' : [ 'blue' , 'lightgreen' ]}, 'Land mask' )
# Apply the single-band land mask to all image bands pixel values equal to 0
# in the mask become invalid in the image.
img_masked = img . updateMask ( land_mask )
display ( 'Image, land only' , img_masked )
m . add_layer ( img_masked , true_color_viz , 'Image, land only' )
# Masks are band-specific. Here, a multi-band mask image is used to update
# corresponding input image band masks.
img_band_subset = img . select ([ 'B4' , 'B3' , 'B2' ])
band_specific_masks = img_band_subset . gt ( 200 )
img_band_subset_masked = img_band_subset . updateMask ( band_specific_masks )
display ( 'Multi-band mask image' , band_specific_masks )
display ( 'Image, variable band masks' , img_band_subset_masked )
m . add_layer ( band_specific_masks , None , 'Multi-band mask image' )
m . add_layer (
img_band_subset_masked , true_color_viz , 'Image, variable band masks'
)
# Note that there is only a single alpha channel for visualization, so when
# the ee.Image is rendered as an RGB image or map tiles, a masked pixel in any
# band will result in transparency for all bands.
# Floating point mask values between 0 and 1 will be used to define opacity
# in visualization via m.add_ee_layer and ee.Image.visualize.
land_mask_float = land_mask . add ( 0.65 )
img_masked_float = img . updateMask ( land_mask_float )
display ( 'Image, partially transparent' , img_masked_float )
m . add_layer ( img_masked_float , true_color_viz , 'Image, partially transparent' )
m
의견 보내기
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스 에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스 에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책 을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
의견을 전달하고 싶나요?
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-26(UTC)"],[],["The `updateMask()` function modifies an image's existing mask. It takes a new mask as input, a floating-point image where 0 denotes invalid and 1 denotes valid pixels. When applied, the function updates all image pixels where the current mask is non-zero. The new mask can be single-band, affecting all input image bands, or multi-band, updating bands individually. Mask values between 0 and 1 indicate partial transparency. The output image keeps the input image's metadata and footprint.\n"]]