当前位置:网站首页>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
边栏推荐
- A new attribute value must be added to the entity entity class in the code, but there is no corresponding column in the database table
- Black Horse Notes - - set Series Collection
- Video cover image setting, put cover images into multiple videos in the simplest way
- List of common bugs in software testing
- C# 基于MQTTNet的服务端与客户端通信案例
- Gee: explore the change of water area in the North Canal basin over the past 30 years [year by year]
- Application of intelligent robot in agricultural ecology
- How to configure PostgreSQL 12.9 to allow remote connections
- el-cascader回显只选中不显示的问题
- Solution: the agent throws an exception error
猜你喜欢
Fabric.js 将本地图像上传到画布背景
黑马笔记---Set系列集合
2022阿里巴巴全球数学竞赛 第4题 虎虎生威(盲盒问题、集卡问题)解决思路
Analyzing the hands-on building tutorial in children's programming
Using Kube bench and Kube hunter to evaluate the risk of kubernetes cluster
Getting started with pytest ----- confitest Application of PY
el form 表单validate成功后没有执行逻辑
Johnson–Lindenstrauss Lemma(2)
C# 基于MQTTNet的服务端与客户端通信案例
Paddlepaddle project source code
随机推荐
About PROFIBUS: communication backbone network of production plant
Pyechart1.19 national air quality exhibition
Creation and destruction of function stack frames
js面试收藏试题1
List of common bugs in software testing
摆正元素(带过渡动画)
数据库批量插入数据
ansible安装与使用
6.30 year end summary, end of student age
Fabric.js 圆形笔刷
奠定少儿编程成为基础学科的原理
Paddlepaddle project source code
Simple and practical accounting software, so that accounts can be checked
Map in JS (including leetcode examples)
Black Horse Notes - - set Series Collection
从数组中找出和为目标的下标
The El cascader echo only selects the questions that are not displayed
Acelems Expressway microgrid energy efficiency management platform and intelligent lighting solution intelligent lighting tunnel
A new attribute value must be added to the entity entity class in the code, but there is no corresponding column in the database table
LeetCode 1175. Prime number arrangement (prime number judgment + Combinatorial Mathematics)