当前位置:网站首页>Google Earth engine -- null value problem in image statistics
Google Earth engine -- null value problem in image statistics
2022-07-23 16:01:00 【This star is bright】
Here's a question , Is there only one image , But here we need to look at the code , The function used in the code is raw data filtering , then This function is equal to , Equal to the value of a single image id
filterMetadata(name, operator, value)
deleted . Use filter() And ee.Filter.eq(), ee.Filter.gte() etc. .
A shortcut to filter a collection through metadata . This is equivalent to this.filter(ee.Filter.metadata(..)).
Return filtered collection .
Parameters .
this:collection( aggregate ).
Collection instance .
name( character string ).
Name of the attribute to be filtered .
operator (String):
The name of the comparison operator . The possible value is ."equals", "less_than", "greater_than",
"not_equals", "not_less_than", "not_greater_than", "start_with",
"end_with", "not_starts_with", "not_ends_with", " contains",
" It doesn't contain ".
value( object ).
- The value to compare .
return . aggregate
So here is the first question to explain why there are only single scene images


The second problem here is that when we count the function of single scene image here, we return the statistical value to an empty vector , Therefore, the statistical value is not given here , And here we choose first, That is, the first choice shp The vector itself here is a null value
| SCL | Scene Classification Map (The "No Data" value of 0 is masked out) | 1 | 11 | 20 meters | 0 |
Class Table: SCL Here is the specific classification information
| Value | Color | Color Value | Description |
|---|---|---|---|
| 1 | #ff0004 | Saturated or defective | |
| 2 | #868686 | Dark Area Pixels | |
| 3 | #774b0a | Cloud Shadows | |
| 4 | #10d22c | Vegetation | |
| 5 | #ffff52 | Bare Soils | |
| 6 | #0000ff | Water | |
| 7 | #818181 | Clouds Low Probability / Unclassified | |
| 8 | #c0c0c0 | Clouds Medium Probability | |
| 9 | #f1f1f1 | Clouds High Probability | |
| 10 | #bac5eb | Cirrus | |
| 11 | #52fff9 | Snow / Ice |
SLC Band will be removed 0 The data of
Code :
// Image filtering here is the filtering of single scene images
var S2 = ee.ImageCollection('COPERNICUS/S2_SR')
.filterMetadata("system:index", 'equals', '20210705T165901_20210705T165855_T20XNN')
// Define a cloud masking function .
var maskcloud1 = function(image) {
var QA60 = image.select(['QA60']);
return image.updateMask(QA60.lt(1))
};
// Define a vegetation masking function . You need to see the image information of this band
var masklandcover = function(image){
var SCL = image.select(['SCL']);
return image.updateMask(SCL.eq(4).or(SCL.eq(5)).or(SCL.eq(6)).or(SCL.eq(11)))
}
// The choice is greater than 0 Of
var maskpstv = function(image){
var RE = image.select(['AbsError']);
return image.updateMask(RE.gte(0))
}
// Choose less than 0 Of
var maskngtv = function(image){
var RE = image.select(['AbsError']);
return image.updateMask(RE.lt(0))
}
var AbsoluteError_oldc_f = function(image) {
return image.expression(
'((2.5 * (NIR - RED) / (NIR + (6-7.5/2.08)*RED + 1))-(2.5 * (NIR - RED) / (NIR + 6*RED-7.5*BLUE + 1)))',
{
'NIR': image.select('B8').multiply(0.0001),
'RED': image.select('B4').multiply(0.0001),
'BLUE': image.select('B2').multiply(0.0001),
}).rename('AbsError').copyProperties(image, image.propertyNames());
};
// Use the image to do the above map Work
var ImgsMasked = S2.map(maskcloud1).map(masklandcover).map(AbsoluteError_oldc_f);
// Then filter for greater than and less than
var ImgsMasked_pstv = ImgsMasked.map(maskpstv)
var ImgsMasked_ngtv = ImgsMasked.map(maskngtv)
// Find the average value of the image
var BecomeTs = function(image){
var date = image.get("DATE_ACQUIRED")//.format("Y-M-D");
var mean = image.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: image.geometry(),
scale: 10,
bestEffort: true
});
//
// And return a with "null " Characteristics of geometry , With attributes ( Dictionaries ).
return ee.Feature(null, {'mean': mean.get('AbsError'), 'date': date,'geometry':image.geometry().coordinates()})
}
print('ImgsMasked_ngtv',ImgsMasked_ngtv)
// There is only one image with name 20210705T165901_20210705T165855_T20XNN
print('Result using map() function', ImgsMasked_ngtv.map(BecomeTs))
// get the mean value -119345390125318.16
print('Result using first() function',BecomeTs(ImgsMasked_ngtv.first()))
// get the mean value null


边栏推荐
- The difference between cookies and sessions
- Mathematical Modeling Typesetting
- Vim到底可以配置得多漂亮?
- 适用于顺序磁盘访问的1分钟法则
- 3D math - vector
- TranslucentTB 推荐
- 可穿戴设备的自电容触摸控制器IT7259Q-13,IT7259EX-24
- [attack and defense world web] difficulty Samsung 9 points introductory question (Part 1): simple_ js、mfw
- On 'premature optimization'
- Software testing weekly (No. 81): what can resist negativity is not positivity, but concentration; What can resist anxiety is not comfort, but concrete.
猜你喜欢
随机推荐
sqlnet. Ora-12154 and ora-01017 connection exceptions caused by incorrect ora file settings
Opnsense - multifunctional, highly reliable and easy-to-use firewall (II)
Design idea of initializing page input parameters
xml-xxe漏洞之Fake XML cookbook
浅谈‘过早优化’
忘记oracle密码,如何解决
Alamofire 框架封装与使用
服务器性能调优经验总结
Redis的过期策略以及内存淘汰机制,Key过期了为什么没释放内存
对C语言最基本的代码解释
Safe and reasonable use of electricity to harvest a cool "summer"
太拼了!腾讯T4大佬凌晨4点还在熬夜,竟是在整理这分布式事务笔记
TranslucentTB 推荐
Redis master-slave replication
Learning summary of ugly code
[attack and defense world web] difficulty Samsung 9 points introductory question (Part 1): simple_ js、mfw
On 'premature optimization'
手机使用多了可能会丢掉工作
後綴錶達式(暑假每日一題 4)
PHP代码审计4—Sql注入漏洞









