GEE面积过滤器

计算多边形面积属性用于过滤多边形对象

主要功能

找出美国所有面积小于3000平方千米的县

代码

// Computed area filter.
// Find US counties smaller than 3k square kilometers in area.

// Load counties from TIGER boundaries table
var counties = ee.FeatureCollection('TIGER/2016/Counties');

// Map a function over the counties to set the area of each.
var countiesWithArea = counties.map(function(f) {
  // Compute area in square meters.  Convert to hectares.
  var areaHa = f.area().divide(100 * 100);

  // A new property called 'area' will be set on each feature.
  return f.set({area: areaHa});
});

// Filter to get only smaller counties.
var smallCounties = countiesWithArea.filter(ee.Filter.lt('area', 3e5));

Map.addLayer(smallCounties, {color: '900000'});

Map.setCenter(-119.7, 38.26, 7);

步骤分析

  1. 使用已有的要素集筛选特定图层
  2. 计算县图层中所有要素的面积,返回指定单位面积结果
  3. 使用面积计算结果来过滤数据
  4. 添加筛选结果图层
  5. 设置地图中心,缩放等级

主要方法

  1. ee.Feature.area()
    Returns the area of the feature's default geometry. Area of points and line strings is 0, and the area of multi geometries is the sum of the areas of their componenets (intersecting areas are counted multiple times).
    Arguments:
    this:feature (Element):
    The feature from which the geometry is taken.
    maxError (ErrorMargin, default: null):
    The maximum amount of error tolerated when performing any necessary reprojection.
    proj (Projection, default: null):
    If specified, the result will be in the units of the coordinate system of this projection. Otherwise it will be in square meters.
    Returns: Float

返回要素特征的面积(默认投影)。点,线要素的面积为0,复杂多边形返回多个多边形面积总和,重叠部分多次计算。
输入参数:要素、容差、投影坐标系。
返回值:浮点型面积值。

  1. ee.Feature.set()
    Overrides one or more metadata properties of an Element.
    Returns the element with the specified properties overridden.
    Arguments:
    this:element (Element):
    The Element instance.
    var_args (VarArgs):
    Either a dictionary of properties, or a vararg sequence of properties, e.g. key1, value1, key2, value2, ...
    Returns: Element

    设置或者重写一个或多个要素特征。
    输入参数:要素,属性赋值语句。赋值语句可以是字典,列表均可。
    返回值:设定了新参数,或者重写旧参数的要素。

    你可能感兴趣的:(GEE面积过滤器)