当前位置:网站首页>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 ExchangevarbitwiseExtract = function(input, fromBit, toBit) { varmaskSize = ee.Number(1).add(toBit).subtract(fromBit) varmask = ee.Number(1).leftShift(maskSize).subtract(1) returninput.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 | varmodisLST = ee.ImageCollection("MODIS/006/MOD11A1")varlsib = ee.FeatureCollection("USDOS/LSIB_SIMPLE/2017")varaustralia = lsib.filter(ee.Filter.eq('country_na', 'Australia'))vargeometry = australia.geometry()varterra = modisLST .filter(ee.Filter.date('2001-01-01', '2010-01-01')) .select('LST_Day_1km','QC_Day'); // Get a single image for testingvarimage = ee.Image(terra.first())varlstDay = image.select('LST_Day_1km')varqcDay = 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)varqaMask = bitwiseExtract(qcDay, 0, 1).lte(1)vardataQualityMask = bitwiseExtract(qcDay, 2, 3).eq(0)varlstErrorMask = bitwiseExtract(qcDay, 6, 7).eq(0)varmask = qaMask.and(dataQualityMask).and(lstErrorMask)varlstDayMasked = lstDay.updateMask(mask) varvisParams = {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

边栏推荐
- Fabric.js 将本地图像上传到画布背景
- No logic is executed after the El form is validated successfully
- The El cascader echo only selects the questions that are not displayed
- Basic differences between Oracle and MySQL (entry level)
- Future trend of automated testing ----- self healing technology
- Fabric.js IText 上标和下标
- Summary of database problems
- Splice characters in {{}}
- Learn BeanShell before you dare to say you know JMeter
- Set the default style of scroll bar Google browser
猜你喜欢

How to configure PostgreSQL 12.9 to allow remote connections

paddle: ValueError:quality setting only supported for ‘jpeg‘ compression

About PROFIBUS: communication backbone network of production plant

Getting started with pytest ----- confitest Application of PY

2022 Alibaba global mathematics competition, question 4, huhushengwei (blind box problem, truck problem) solution ideas

Record my pytorch installation process and errors
![[high speed bus] Introduction to jesd204b](/img/78/1a0a3672e63058da6d98da95aa3cf2.jpg)
[high speed bus] Introduction to jesd204b

Black Horse Notes - - set Series Collection

Disable access to external entities in XML parsing

Cubemx DMA notes
随机推荐
06 装饰(Decorator)模式
数学知识(欧拉函数)
Practical problem solving ability of steam Education
Fabric.js 精简JSON
【pyinstaller】_get_sysconfigdata_name() missing 1 required positional argument: ‘check_exists‘
Mathematical knowledge (Euler function)
Cubemx DMA notes
Dark horse notes -- Set Series Collection
Cultivate primary and secondary school students' love for educational robots
National all Chinese Automatic Test Software apifox
Global and Chinese market of commercial fish tanks 2022-2028: Research Report on technology, participants, trends, market size and share
Johnson–Lindenstrauss Lemma(2)
数据库问题汇总
fastText文本分类
C # picture display occupancy problem
2022 Alibaba global mathematics competition, question 4, huhushengwei (blind box problem, truck problem) solution ideas
Implementation of leetcode two number addition go
LeetCode 1175. 质数排列(质数判断+组合数学)
Global and Chinese market of cell culture freezers 2022-2028: Research Report on technology, participants, trends, market size and share
从数组中找出和为目标的下标