Google Earth Engine(GEE)——ee.Reducer.percentile使用过程中的注意问题

我们在获取影像的百分比值使用的函数是ee.Reducer.percentile,但是会存在很多问题有时候会发现我们获取不同百分比值的时候数值会不一样,可能导致结果不同。

问题:

对于单波段图像,第5、25、50、75和95百分位数的值是相同的。尽管图像中存在离群点,但这很难理解,因为离群点像素的数量比正常像素的数量少得多。如何自动去除离群点?

函数:

ee.Reducer.percentile(percentiles, outputNamesmaxBucketsminBucketWidthmaxRaw)

Create a reducer that will compute the specified percentiles, e.g. given [0, 50, 100] will produce outputs named 'p0', 'p50', and 'p100' with the min, median, and max respectively. For small numbers of inputs (up to maxRaw) the percentiles will be computed directly; for larger numbers of inputs the percentiles will be derived from a histogram.

Arguments:

percentiles (List):

A list of numbers between 0 and 100.

outputNames (List, default: null):

A list of names for the outputs, or null to get default names.

maxBuckets (Integer, default: null):

The maximum number of buckets to use when building a histogram; will be rounded up to a power of 2.

minBucketWidth (Float, default: null):

The minimum histogram bucket width, or null to allow any power of 2.

maxRaw (Integer, default: null):

The number of values to accumulate before building the initial histogram.

Returns: Reducer

代码:

var    geometry = 
    /* color: #d63000 */
    /* shown: false */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[116.01553161700186, 37.83468958950668],
          [116.01553161700186, 36.86089892709646],
          [117.21304138262686, 36.86089892709646],
          [117.21304138262686, 37.83468958950668]]], null, false);

var image=ee.ImageCollection("JAXA/ALOS/AW3D30/V3_2").select("DSM").filterBounds(geometry).mosaic().clip(geometry)

//original 
var list1 = image.reduceRegion(ee.Reducer.percentile([5,25,50,75,95]),geometry,10,null,null,false,1e12)
print(list1) // the value of each percentile is same

var chart = ui.Chart.image.histogram({
  image:image, 
  region:geometry,
  scale:10,
  minBucketWidth:0.1, 
  maxPixels:1e12
});

print('image historgram with outliers:',chart)

// munmual change outliers
var image2 = image.where(image.gt(10),10)

var list2 = image2.reduceRegion(ee.Reducer.percentile([5,25,50,75,95]),geometry,10,null,null,false,1e12)
print(list2)

var chart2 = ui.Chart.image.histogram({
  image:image2, 
  region:geometry,
  scale:10,
  minBucketWidth:0.1, 
  maxPixels:1e12
});

print('image historgram without outliers:',chart2)


//修改后的代码///
// Finding the 5th and 95th percentile

var  image_95 = image.reduceRegion({
        'reducer': ee.Reducer.percentile({
            'percentiles': [1, 5,25,50,75,95],
            'maxRaw': 1000000,
            'maxBuckets': 1000000,
            'minBucketWidth': 0.00000000001
        }),
        'geometry': geometry,
        'scale': 10,
        'maxPixels': 1e13
    });

print(image_95);

 前言 – 床长人工智能教程

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

此星光明

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值