当前位置:网站首页>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
边栏推荐
- Express logistics quick query method, set the unsigned doc No. to refresh and query automatically
- 2022阿里巴巴全球数学竞赛 第4题 虎虎生威(盲盒问题、集卡问题)解决思路
- Here comes the chicken soup! Keep this quick guide for data analysts
- List of common bugs in software testing
- Simple and practical accounting software, so that accounts can be checked
- Rhcsa --- work on the fourth day
- Global and Chinese market of impact roll 2022-2028: Research Report on technology, participants, trends, market size and share
- 農業生態領域智能機器人的應用
- 将光盘中的cda保存到电脑中
- Leetcode basic programming: array
猜你喜欢
[common error] the DDR type of FPGA device is selected incorrectly
数学知识(欧拉函数)
Mysql基础---查询(1天学会mysql基础)
How do I interview for a successful software testing position? If you want to get a high salary, you must see the offer
运维工作的“本手、妙手、俗手”
Mathematical knowledge (Euler function)
Dark horse notes -- Set Series Collection
Pytest learning ----- pytest Interface Association framework encapsulation of interface automation testing
摆正元素(带过渡动画)
Preparation for writing SAP ui5 applications using typescript
随机推荐
摆正元素(带过渡动画)
The reason why sizeof (ARR) / sizeof (arr[0]) is used in the function to calculate the length of the array is incorrect
How to configure PostgreSQL 12.9 to allow remote connections
Pyflink writes MySQL examples with JDBC
CubeMx DMA笔记
fastText文本分类
C # picture display occupancy problem
国产全中文-自动化测试软件Apifox
leetcode存在重复元素go实现
Summary of database problems
C case of communication between server and client based on mqttnet
How do I interview for a successful software testing position? If you want to get a high salary, you must see the offer
函数中使用sizeof(arr) / sizeof(arr[0])求数组长度不正确的原因
Global and Chinese market of insulin pens 2022-2028: Research Report on technology, participants, trends, market size and share
Disable access to external entities in XML parsing
Summary of MySQL key challenges (2)
Paddlepaddle project source code
js面试收藏试题1
C# 基于MQTTNet的服务端与客户端通信案例
js中的Map(含leetcode例题)