当前位置:网站首页>Gee: use of common mask functions in remote sensing image processing [updatemask]
Gee: use of common mask functions in remote sensing image processing [updatemask]
2022-07-02 05:11:00 【Gee water ecological space】
To learn, you must be rigid and constant , If it's not rigid, it's easy , If it doesn't last, it will fall back .—— The song dynasty . Fengzixian
Preface
GEE The mask correlation function in 3 individual , Respectively mask、updateMask and unmask, Need to differentiate and master 3 Usage of mask function
One 、mask() function
- ee.Image.mask()

Get or set the mask of the image . The output image retains the metadata and footprints of the input image . Pixels whose mask changes from zero to another value will be filled with zero , Or the value closest to zero in the range of pixel types .
Mask image . If specified , Then copy the input image to the output , But the mask is given by the value of the image . If this is a single band , Then it is used for all bands in the input image . If not specified , Returns the image created from the mask of the input image , Zoom to range 0:1.
Be careful : The version that sets the mask will be deprecated . To mask an image on a previously unmasked pixel , Please use Image.updateMask. To unshield previously masked pixels , Please use Image.unmask.
Usage method :image.mask(), Will use the mask area and non mask area of the image 0 and 1 Distinguish , among 1 Represented by mask ,0 Represents unmasked . Within the frame of the image , Black represents the masked area , White represents the unmasked area .
Two 、updateMask()
ee.Image.updateMask()

Update the mask of the image in all positions where the existing mask is not zero . The output image retains the metadata and footprints of the input image .
New mask for image , As 0, 1 Floating point values in range . If this image has a band , It is used to input all bands in the image ; otherwise , It must have the same number of bands as the input image .
Usage method :image.updateMask(),updateMask The image will be shown as 0 The area mask of , If you want one image to have the same mask as another , have access to image2.updateMask(image1.mask().not()).
3、 ... and 、unmask()
ee.Image.unmask()

In all positions where the input mask is zero , Replace the mask and value of the input image with the mask and value of another image . The output image retains the metadata of the input image . By default , The output image also retains the imported footsteps , But will sameFootprint Set to false Allow extended footsteps .
Usage method ,image.unmask(number),unmask Its function is that it can replace the image value of the masked area with any value , The unmasked area remains the original value . for example image.unmask(-9999) The value in the masked area will be replaced by -9999, In this way, the image can be compared with arcgis Seamless compatibility .
Four 、 Case practice
python The code is as follows :
(1) Image data
image = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')
trueColor = {
'bands':['B4', 'B3', 'B2'],
'min':0, 'max':2800,
'gamma':1.5
}
# Load image
Map = geemap.Map()
Map.addLayer(image, trueColor, 's2 image')
Map.centerObject(image)
Map(2) Corresponding mask processing
# ********** Replace all mask areas with a certain value , Use unmask**********
# # ********** Mask out unqualified pixels , Use updateMask**********
# utilize SWIR1 establish land Boolean band , among water by 0,land by 1
landMask = image.select('B11').gt(100)
# Apply mask band to update the original image , It will make the mask on the image equal to 0 All pixels of become invalid values
imageMasked = image.updateMask(landMask) # Only reserved land
# Load two images , landMask The image can be clearly divided into 2 Color ,0 For blue ,1 It's green
Map.addLayer(landMask, {'palette': ['blue', 'lightgreen']}, 'Land mask')
Map.addLayer(imageMasked, trueColor, 'imageMasked')
# ********** Replace all mask areas with a certain value , Use unmask**********
# Set invalid mask value , Replace the unmasked area with 32767 Null value appears
imageUnmasked = imageMasked.unmask(32767)
Map.addLayer(imageUnmasked, trueColor, 'image unmasked')
# Reset mask pixels to valid , Use the default value 0 fill , Enter footsteps
maskResetFootprint = imageMasked.unmask()
Map.addLayer(maskResetFootprint, trueColor, 'maskResetFootprint')
# Use something else 1 Image pixel value replacement
fill = ee.Image('COPERNICUS/S2_SR/20200618T184919_20200618T190341_T10SEG')
imgFill = imageMasked.unmask(fill)
Map.addLayer(fill, trueColor, 'new s2')
Map.addLayer(imgFill, trueColor, 'image filled')The results are illustrated below :

5、 ... and 、 Summary
- GEE in 3 A common mask function ,mask, updateMask and unmask, among mask As a function about to be discarded , It is not recommended to use too much . It can be used flexibly updateMask and Mask Realize data processing and analysis .
- Using mask analysis , It can realize the magical function of transplanting flowers and trees , It is interesting to
Reference resources :
- https://developers.google.com/earth-engine/apidocs/ee-image-unmask?hl=en
- https://blog.csdn.net/SunStrongInChina/article/details/110388401
边栏推荐
- Getting started with pytest ----- confitest Application of PY
- Global and Chinese market of commercial fish tanks 2022-2028: Research Report on technology, participants, trends, market size and share
- 摆正元素(带过渡动画)
- MMAP zero copy knowledge point notes
- 在{{}}中拼接字符
- Nodejs (02) - built in module
- LS1046nfs挂载文件系统
- Mysql基础---查询(1天学会mysql基础)
- Fabric.js 将本地图像上传到画布背景
- Using Kube bench and Kube hunter to evaluate the risk of kubernetes cluster
猜你喜欢

解决:代理抛出异常错误

Nodejs (02) - built in module
![[common error] the DDR type of FPGA device is selected incorrectly](/img/f3/be66bcfafeed581add6d48654dfe34.jpg)
[common error] the DDR type of FPGA device is selected incorrectly

Cubemx DMA notes

Mathematical knowledge -- understanding and examples of fast power

No logic is executed after the El form is validated successfully

Lm09 Fisher inverse transform inversion mesh strategy

解析少儿编程中的动手搭建教程

C# 基于MQTTNet的服务端与客户端通信案例

2022 Alibaba global mathematics competition, question 4, huhushengwei (blind box problem, truck problem) solution ideas
随机推荐
函数栈帧的创建和销毁
Splice characters in {{}}
数学知识(欧拉函数)
No logic is executed after the El form is validated successfully
Preparation for writing SAP ui5 applications using typescript
Mysql重点难题(2)汇总
Cultivate primary and secondary school students' love for educational robots
MMAP zero copy knowledge point notes
Leetcode18题 【四数之和】递归解法
黑马笔记---Set系列集合
Future trend of automated testing ----- self healing technology
Global and Chinese market of cell culture freezers 2022-2028: Research Report on technology, participants, trends, market size and share
Oracle和MySQL的基本区别(入门级)
Steam教育的实际问题解决能力
7.1 Résumé du concours de simulation
Lay the foundation for children's programming to become a basic discipline
Go GC garbage collection notes (three color mark)
How to configure PostgreSQL 12.9 to allow remote connections
C# 图片显示占用问题
10 minute quick start UI automation ----- puppeter