Google Earth Engine(GEE)—— 超限超时提取的问题(besteffort的适用)

  • 当您有超过 10000000 个像素时,bestEffort 参数将仅使用像素子集来计算统计信息。如果您想要实际的最小值/最大值,请将 maxPixels 设置为更高的数字
  • 使用图层管理器​​计算的参数是使用您所在缩放级别的地图中可见像素的子集完成的。 ( 参考)。可以得到近似的最小值/最大值
  • 如果您想要实际的最小/最大值,则需要以原始比例(30m)为整个几何图形运行计算

推荐的方法是使用 evaluate() 异步计算统计数据并在完成后添加图层。请记住,evaluate() 返回一个客户端对象,您必须使用 javascript 方法从对象中提取值。 

函数:

reduceRegion(reducer, geometryscalecrscrsTransformbestEffortmaxPixelstileScale)

Apply a reducer to all the pixels in a specific region.

Either the reducer must have the same number of inputs as the input image has bands, or it must have a single input and will be repeated for each band.

Returns a dictionary of the reducer's outputs.

Arguments:

this:image (Image):

The image to reduce.

reducer (Reducer):

The reducer to apply.

geometry (Geometry, default: null):

The region over which to reduce data. Defaults to the footprint of the image's first band.

scale (Float, default: null):

A nominal scale in meters of the projection to work in.

crs (Projection, default: null):

The projection to work in. If unspecified, the projection of the image's first band is used. If specified in addition to scale, rescaled to the specified scale.

crsTransform (List, default: null):

The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with 'scale', and replaces any transform already set on the projection.

bestEffort (Boolean, default: false):

If the polygon would contain too many pixels at the given scale, compute and use a larger scale which would allow the operation to succeed.如果多边形在给定的比例下包含太多的像素,则计算并使用一个更大的比例,这样可以使操作成功。

maxPixels (Long, default: 10000000):

The maximum number of pixels to reduce.要统计的最大像素数。

tileScale (Float, default: 1):

A scaling factor between 0.1 and 16 used to adjust aggregation tile size; setting a larger tileScale (e.g. 2 or 4) uses smaller tiles and may enable computations that run out of memory with the default.

Returns: Dictionary

代码:

var ss = ee.FeatureCollection("users/bqt2000204051/Qinghai");
var NDVIImgColl = ee.ImageCollection('LANDSAT/LC08/C01/T1_8DAY_NDVI')
                  .filterDate('2018-11-01', '2019-04-30').select('NDVI').mean();
                  
                  
Map.addLayer(NDVIImgColl.clip(ss), {}, "NDVI")

var NDVIavg = NDVIImgColl.clip(ss)

var stats = NDVIavg.reduceRegion({
    reducer: ee.Reducer.minMax(),
    geometry : ss,
    scale : 30,
    maxPixels: 1e10
  });

var varmax1 = ee.Number(stats.get("NDVI_max"));
print("Max NDVI in AOI", varmax1)

// evaluate() 将在后台运行,而 最小/最大值的计算
stats.evaluate(function(result) {
  var min = result['NDVI_min']
  var max = result['NDVI_max']
  print('Computed min/max', min, max)
  var visParams = {min: min, max:max}
  Map.addLayer(NDVIImgColl.clip(ss), visParams, 'Min/Max Stretch');
})

这里没有best effort的运行状态,一致再加载:

var stats = NDVIavg.reduceRegion({
    reducer: ee.Reducer.minMax(),
    geometry : ss,
    scale : 30,
    maxPixels: 1e10,
bestEffort:true
  });

使用后的bestEffort参数结果:

NDVI均值:

 最大最小值:

猜你喜欢

转载自blog.csdn.net/qq_31988139/article/details/123819108