- 当您有超过 10000000 个像素时,bestEffort 参数将仅使用像素子集来计算统计信息。如果您想要实际的最小值/最大值,请将 maxPixels 设置为更高的数字
- 使用图层管理器计算的参数是使用您所在缩放级别的地图中可见像素的子集完成的。 ( 参考)。可以得到近似的最小值/最大值
- 如果您想要实际的最小/最大值,则需要以原始比例(30m)为整个几何图形运行计算
推荐的方法是使用 evaluate() 异步计算统计数据并在完成后添加图层。请记住,evaluate() 返回一个客户端对象,您必须使用 javascript 方法从对象中提取值。
函数:
reduceRegion(reducer, geometry, scale, crs, crsTransform, bestEffort, maxPixels, tileScale)
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
代码:
这里没有best effort的运行状态,一致再加载:
使用后的bestEffort参数结果:
NDVI均值:
最大最小值: