GEE数据集距离计算

标记特定像素

主要功能

标记大于1000m的像素点,标记等于1000m的像素点

代码

// Collection.distance example.
// Computes the distance to the nearest feature in a collection.

// Construct a FeatureCollection from a list of geometries.
var fc = ee.FeatureCollection([
  ee.Geometry.Point(-72.94411, 41.32902),
  ee.Geometry.Point(-72.94411, 41.33402),
  ee.Geometry.Point(-72.94411, 41.33902),
  // The geometries do not need to be the same type.
  ee.Geometry.LineString(
      -72.93411, 41.30902, -72.93411, 41.31902, -72.94411, 41.31902)
]);

// Compute distance from the dfeatures, to a max of 1000 meters.
var distance = fc.distance(1000, 100);

Map.setCenter(-72.94, 41.32, 13);
Map.addLayer(distance, {min: 0, max: 1000, palette: ['yellow', 'red']});
Map.addLayer(fc);

步骤分析

  1. 创建ee对象,使用自定义坐标来创建的了点和线的混合要素集合。
  2. 计算与要素距离在设置范围中的部分。
  3. 添加图层,设置显示方式。

主要方法

  1. ee.feature.distance()
    Returns the minimum distance between the geometries of two features.
    Arguments:
    this:left (Element): The feature containing the geometry used as the left operand of the operation.
    right (Element): The feature containing the geometry used as the right operand of the operation.
    maxError (ErrorMargin, default: null): The maximum amount of error tolerated when performing any necessary reprojection.
    proj (Projection, default: null): The projection in which to perform the operation. If not specified, the operation will be performed in a spherical coordinate system, and linear distances will be in meters on the sphere.

计算两个地理要素之间的最小距离。
输入参数: 左操作数(计算结果)、右操作数(计算使用的要素)、容差、投影坐标系。
返回值:浮点型地理要素距离计算结果。

你可能感兴趣的:(GEE数据集距离计算)