当前位置:网站首页>Using QA band and bit mask in Google Earth engine
Using QA band and bit mask in Google Earth engine
2022-07-02 05:11:00 【Gee water ecological space】
stay Google Used in the earth engine QA Band and bit mask
Most optical satellite image products come with one or more QA Band , Allows users to evaluate the quality of each pixel and extract pixels that meet their requirements .QA The most common application of band is to extract information about cloudy pixels and mask them . however QA The band contains a lot of other information , Can help you remove low-quality data from your analysis . Usually ,QA The information contained in the frequency band is stored as a bitwise flag . In this article , I will introduce the basic concepts related to bit operation , And how to use bit mask to extract and mask specific quality indicators .
For this article , We will use MOD11A1.006 Terra Land Surface Temperature and Emissivity Daily Global 1km Data sets . But these concepts and code snippets can be easily applied to any other data set . View band metadata , We see LST_Day_1km
The band is accompanied by a QC_Day
contain LST Band of quality index .
understand QA sign
The QC_day
Band contains 8 Bit information . This means that the range of pixel values can range from 0 To 255. This band stores 4 A different indicator , Every indicator has 4 Possible values . Each combination of these values produces a different 8 Digit number , This number is stored in the output . We can understand how to explain these through a specific example QA position . Suppose you will QC_Day
Add a band to the map and check a pixel . The value of this pixel is 145. What's the meaning of this? ? Um. , value 145 Is each QA The result of setting the flag to a specific value .
Tips : Use this convenient Decimal to binary converter To understand the binary representation of numbers , vice versa .
The following figure decomposes values into bit pairs and shows how to interpret them .
Understand bit masks
Suppose you want to query QA Band median 4-5 All pixels set to a specific value . You will need to extract the storage location 4-5 Information in , Ignore all other bits at the same time . This can be used Bitmask To achieve . In short , The bit mask will retain the information in the bits of interest , And set all other values to 0.
You can use shift left (<<) And move right (>>) Operator to create a bitmask .GEE API Provide leftShift()
and rightShift()
function . After creating the bitmask , have access to () Function applies it to the input image . The following is a specific location extraction GEE API function .ee.Image()
ee.Number()
bitwiseAnd
1 2 3 4 5 6 7 8 | // Helper function to extract the values from specific bits // The input parameter can be a ee.Number() or ee.Image() // Code adapted from google earth engine - Creating Cloud free images out of a MOD09A1 MODIS image in GEE? - Geographic Information Systems Stack Exchange var bitwiseExtract = function (input, fromBit, toBit) { var maskSize = ee.Number(1).add(toBit).subtract(fromBit) var mask = ee.Number(1).leftShift(maskSize).subtract(1) return input.rightShift(fromBit).bitwiseAnd(mask) } |
To understand this code , Please look at the chart below. . We will continue with the example in the previous section , And try to understand the working principle of the algorithm by answering the following questions : Numbers 145 No 4 Position and number 5 What is the value of the bit ?
Shield low-quality data
Now let's put all these together , See how we shield MODIS LST Low quality data in the image . Our goal is to use wavebands and extract from images QC_day
Extract all pixels LST_Day_1km
- QA sign ( position 0-1) by 0 or 1(LST Good quality of production and other quality )
- Data quality mark ( position 2-3) by 0( Good data quality )
- LST Error flag ( position 6-7) by 0( Average LST error ≤ 1K)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | var modisLST = ee.ImageCollection( "MODIS/006/MOD11A1" ) var lsib = ee.FeatureCollection( "USDOS/LSIB_SIMPLE/2017" ) var australia = lsib.filter(ee.Filter.eq( 'country_na' , 'Australia' )) var geometry = australia.geometry() var terra = modisLST .filter(ee.Filter.date( '2001-01-01' , '2010-01-01' )) .select( 'LST_Day_1km' , 'QC_Day' ); // Get a single image for testing var image = ee.Image(terra.first()) var lstDay = image.select( 'LST_Day_1km' ) var qcDay = image.select( 'QC_Day' ) // Let's extract all pixels from the input image where // Bits 0-1 <= 1 (LST produced of both good and other quality) // Bits 2-3 = 0 (Good data quality) // Bits 4-5 Ignore, any value is ok // Bits 6-7 = 0 (Average LST error ≤ 1K) var qaMask = bitwiseExtract(qcDay, 0, 1).lte(1) var dataQualityMask = bitwiseExtract(qcDay, 2, 3).eq(0) var lstErrorMask = bitwiseExtract(qcDay, 6, 7).eq(0) var mask = qaMask.and(dataQualityMask).and(lstErrorMask) var lstDayMasked = lstDay.updateMask(mask) var visParams = {min:13000, max:16000, palette: ['green ', ' yellow ', ' red ']} Map.addLayer(lstDay.clip(geometry), visParams, ' Original LST Image '); Map.addLayer(lstDayMasked.clip(geometry), visParams, ' LST Masked'); |
Original image and masked image
边栏推荐
- Go Chan's underlying principles
- Fabric.js 精简JSON
- Cultivate primary and secondary school students' love for educational robots
- How do I interview for a successful software testing position? If you want to get a high salary, you must see the offer
- Splice characters in {{}}
- 黑马笔记---Set系列集合
- 在{{}}中拼接字符
- Using Kube bench and Kube hunter to evaluate the risk of kubernetes cluster
- Pytest learning ----- pytest assertion of interface automation testing
- Preparation for writing SAP ui5 applications using typescript
猜你喜欢
Disable access to external entities in XML parsing
Knowledge arrangement about steam Education
将光盘中的cda保存到电脑中
Fabric.js 将本地图像上传到画布背景
Pytest learning ----- pytest Interface Association framework encapsulation of interface automation testing
培养中小学生对教育机器人的热爱之心
2022 Alibaba global mathematics competition, question 4, huhushengwei (blind box problem, truck problem) solution ideas
创新永不止步——nVisual网络可视化平台针对Excel导入的创新历程
Mathematical problems (number theory) trial division to judge prime numbers, decompose prime factors, and screen prime numbers
Latest: the list of universities and disciplines for the second round of "double first-class" construction was announced
随机推荐
[quick view opencv] familiar with CV matrix operation with image splicing examples (3)
Analyzing the hands-on building tutorial in children's programming
Fabric.js 基础笔刷
ubuntu20.04安装mysql8
培养中小学生对教育机器人的热爱之心
leetcode存在重复元素go实现
No logic is executed after the El form is validated successfully
4. Flask cooperates with a tag to link internal routes
在{{}}中拼接字符
Fabric.js IText 上标和下标
运维工作的“本手、妙手、俗手”
How do I interview for a successful software testing position? If you want to get a high salary, you must see the offer
The El cascader echo only selects the questions that are not displayed
paddle: ValueError:quality setting only supported for ‘jpeg‘ compression
Basic differences between Oracle and MySQL (entry level)
Lay the foundation for children's programming to become a basic discipline
Global and Chinese market of commercial fish tanks 2022-2028: Research Report on technology, participants, trends, market size and share
Fabric.js 自由绘制矩形
Global and Chinese market of insulin pens 2022-2028: Research Report on technology, participants, trends, market size and share
Cubemx DMA notes